Skip to content

Commit

Permalink
Merge branch 'main' into fix-be-consistent-in-tag-check
Browse files Browse the repository at this point in the history
  • Loading branch information
alexgarel authored Jul 23, 2024
2 parents f113c83 + 7205277 commit c43455a
Show file tree
Hide file tree
Showing 191 changed files with 176,910 additions and 173,075 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,4 @@ taxonomies/*.all.txt

# Shared services and other dependencies
/deps
/deps/*
4 changes: 2 additions & 2 deletions cgi/auth.pl
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
use URI::Escape::XS;
use Encode;
use Log::Any qw($log);
use JSON::PP;
use JSON::MaybeXS;

$log->info('start') if $log->is_info();

Expand Down Expand Up @@ -84,7 +84,7 @@
};
}

my $json = JSON::PP->new->allow_nonref->canonical->utf8->encode($response_ref);
my $json = JSON::MaybeXS->new->allow_nonref->canonical->utf8->encode($response_ref);

# We need to send the header Access-Control-Allow-Credentials=true so that websites
# such has hunger.openfoodfacts.org that send a query to world.openfoodfacts.org/cgi/auth.pl
Expand Down
2 changes: 1 addition & 1 deletion cgi/countries.pl
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
use CGI qw/:cgi :form escapeHTML/;
use URI::Escape::XS;
use Encode;
use JSON::PP;
use JSON::MaybeXS;

# This script returns a list of countries in the language of the interface in a JSON format
# it is used to display the dropdown list of countries
Expand Down
2 changes: 1 addition & 1 deletion cgi/import_file_upload.pl
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
use URI::Escape::XS;
use Storable qw/dclone/;
use Encode;
use JSON::PP;
use JSON::MaybeXS;
use Log::Any qw($log);

my $request_ref = ProductOpener::Display::init_request();
Expand Down
2 changes: 1 addition & 1 deletion cgi/import_photos_upload.pl
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
use URI::Escape::XS;
use Storable qw/dclone/;
use Encode;
use JSON::PP;
use JSON::MaybeXS;
use Log::Any qw($log);

my $request_ref = ProductOpener::Display::init_request();
Expand Down
2 changes: 1 addition & 1 deletion cgi/ingredients.pl
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
use URI::Escape::XS;
use Storable qw/dclone/;
use Encode;
use JSON::PP;
use JSON::MaybeXS;
use Log::Any qw($log);

my $request_ref = ProductOpener::Display::init_request();
Expand Down
4 changes: 2 additions & 2 deletions cgi/manifest.pl
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
use URI::Escape::XS;
use Storable qw/dclone/;
use Encode;
use JSON::PP;
use JSON::MaybeXS;

my $request_ref = ProductOpener::Display::init_request();

Expand All @@ -64,7 +64,7 @@
start_url => format_subdomain($subdomain),
scope => '/',
display => 'standalone',
prefer_related_applications => $JSON::PP::true,
prefer_related_applications => $JSON::MaybeXS::true,
);

my @keys = qw(theme_color icons related_applications background_color);
Expand Down
6 changes: 3 additions & 3 deletions cgi/nutrients.pl
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

use Log::Any qw($log);
use CGI qw/:cgi :form escapeHTML/;
use JSON::PP;
use JSON::MaybeXS;

my $request_ref = ProductOpener::Display::init_request();

Expand All @@ -51,9 +51,9 @@
my $nid = $_; # Copy instead of alias

$nid =~ /^#/ and next;
my $important = ($nid =~ /^!/) ? JSON::PP::true : JSON::PP::false;
my $important = ($nid =~ /^!/) ? JSON::MaybeXS::true : JSON::MaybeXS::false;
$nid =~ s/!//g;
my $default_edit_form = $nid =~ /-$/ ? JSON::PP::false : JSON::PP::true;
my $default_edit_form = $nid =~ /-$/ ? JSON::MaybeXS::false : JSON::MaybeXS::true;
$nid =~ s/-$//g;

my $onid = $nid =~ s/^(\-+)//gr;
Expand Down
2 changes: 1 addition & 1 deletion cgi/nutrition.pl
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
use URI::Escape::XS;
use Storable qw/dclone/;
use Encode;
use JSON::PP;
use JSON::MaybeXS;
use Log::Any qw($log);

my $request_ref = ProductOpener::Display::init_request();
Expand Down
2 changes: 1 addition & 1 deletion cgi/opensearch.pl
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
use URI::Escape::XS;
use Storable qw/dclone/;
use Encode;
use JSON::PP;
use JSON::MaybeXS;

use ProductOpener::Lang qw/$lc lang/;

Expand Down
2 changes: 1 addition & 1 deletion cgi/packaging.pl
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
use URI::Escape::XS;
use Storable qw/dclone/;
use Encode;
use JSON::PP;
use JSON::MaybeXS;
use Log::Any qw($log);

my $request_ref = ProductOpener::Display::init_request();
Expand Down
2 changes: 1 addition & 1 deletion cgi/product_image.pl
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
use URI::Escape::XS;
use Storable qw/dclone/;
use Encode;
use JSON::PP;
use JSON::MaybeXS;
use Log::Any qw($log);

my $request_ref = ProductOpener::Display::init_request();
Expand Down
2 changes: 1 addition & 1 deletion cgi/product_image_crop.pl
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
use URI::Escape::XS;
use Storable qw/dclone/;
use Encode;
use JSON::PP;
use JSON::MaybeXS;
use Log::Any qw($log);

my $request_ref = ProductOpener::Display::init_request();
Expand Down
2 changes: 1 addition & 1 deletion cgi/product_image_move.pl
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
use URI::Escape::XS;
use Storable qw/dclone/;
use Encode;
use JSON::PP;
use JSON::MaybeXS;
use Log::Any qw($log);

my $type = single_param('type') || 'add';
Expand Down
2 changes: 1 addition & 1 deletion cgi/product_image_unselect.pl
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
use URI::Escape::XS;
use Storable qw/dclone/;
use Encode;
use JSON::PP;
use JSON::MaybeXS;
use Log::Any qw($log);

my $request_ref = ProductOpener::Display::init_request();
Expand Down
2 changes: 1 addition & 1 deletion cgi/product_image_upload.pl
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
use URI::Escape::XS;
use Storable qw/dclone/;
use Encode;
use JSON::PP;
use JSON::MaybeXS;
use Log::Any qw($log);

my $type = single_param('type') || 'add';
Expand Down
2 changes: 1 addition & 1 deletion cgi/product_jqm_multilingual.pl
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ =head1 DESCRIPTION
use URI::Escape::XS;
use Storable qw/dclone/;
use Encode;
use JSON::PP;
use JSON::MaybeXS;
use Log::Any qw($log);

my $request_ref = ProductOpener::Display::init_request();
Expand Down
2 changes: 1 addition & 1 deletion cgi/product_multilingual.pl
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
use URI::Escape::XS;
use Storable qw/dclone/;
use Encode;
use JSON::PP;
use JSON::MaybeXS;
use Log::Any qw($log);
use File::Copy qw(move);
use Data::Dumper;
Expand Down
2 changes: 1 addition & 1 deletion cgi/recent_changes.pl
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
use URI::Escape::XS;
use Storable qw/dclone/;
use Encode;
use JSON::PP;
use JSON::MaybeXS;

use ProductOpener::Lang qw/:all/;

Expand Down
2 changes: 1 addition & 1 deletion cgi/search.pl
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
use URI::Escape::XS;
use Storable qw/dclone/;
use Encode;
use JSON::PP;
use JSON::MaybeXS;
use Log::Any qw($log);

my $request_ref = ProductOpener::Display::init_request();
Expand Down
2 changes: 1 addition & 1 deletion cgi/session.pl
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
use URI::Escape::XS;
use Storable qw/dclone/;
use Encode;
use JSON::PP;
use JSON::MaybeXS;
use Log::Any qw($log);

my $request_ref = ProductOpener::Display::init_request();
Expand Down
2 changes: 1 addition & 1 deletion cgi/sso.pl
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
use URI::Escape::XS;
use Storable qw/dclone/;
use Encode;
use JSON::PP;
use JSON::MaybeXS;

use ProductOpener::Lang qw/:all/;

Expand Down
2 changes: 1 addition & 1 deletion cgi/sugar_check.pl
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
use CGI::Carp qw(fatalsToBrowser);
use CGI qw/:cgi :form escapeHTML/;
use Encode;
use JSON::PP;
use JSON::MaybeXS;
use Digest::SHA1 qw(sha1_hex);

use ProductOpener::Display qw/single_param/;
Expand Down
2 changes: 1 addition & 1 deletion cgi/sugar_random.pl
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
use CGI::Carp qw(fatalsToBrowser);
use CGI qw/:cgi :form escapeHTML/;
use Encode;
use JSON::PP;
use JSON::MaybeXS;
use Storable qw(lock_store lock_nstore lock_retrieve);
use Apache2::RequestRec ();
use Apache2::Const ();
Expand Down
2 changes: 1 addition & 1 deletion cgi/suggest.pl
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
use CGI qw/:cgi :form escapeHTML/;
use URI::Escape::XS;
use Storable qw/dclone/;
use JSON::PP;
use JSON::MaybeXS;
use Encode;

my $request_ref = ProductOpener::Display::init_request();
Expand Down
4 changes: 2 additions & 2 deletions cgi/test_ingredients_analysis.pl
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
use URI::Escape::XS;
use Storable qw/dclone/;
use Encode;
use JSON::PP;
use JSON::MaybeXS;

use Log::Any qw($log);

Expand Down Expand Up @@ -83,7 +83,7 @@
$template_data_ref->{product_ref} = $product_ref;
$template_data_ref->{preparsed_ingredients_text} = preparse_ingredients_text($lc, $ingredients_text);

my $json = JSON::PP->new->pretty->encode($product_ref->{ingredients});
my $json = JSON::MaybeXS->new->pretty->encode($product_ref->{ingredients});
$template_data_ref->{json} = $json;
}

Expand Down
2 changes: 1 addition & 1 deletion cgi/translate_taxonomy.pl
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
use Encode;
use CGI qw/:cgi :form escapeHTML/;
use Log::Any qw($log);
use JSON::PP;
use JSON::MaybeXS;

my $request_ref = ProductOpener::Display::init_request();

Expand Down
1 change: 1 addition & 0 deletions cpanfile
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ on 'test' => sub {
requires 'Test::File::Contents';
requires 'FindBin';
requires 'Test::Pod';
requires 'UUID';
};

on 'develop' => sub {
Expand Down
1 change: 0 additions & 1 deletion deps/openfoodfacts-shared-services
Submodule openfoodfacts-shared-services deleted from a79f5d
1 change: 1 addition & 0 deletions icons/upload_file.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions lib/ProductOpener/API.pm
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ use ProductOpener::APITaxonomySuggestions qw/taxonomy_suggestions_api/;
use CGI qw(header);
use Apache2::RequestIO();
use Apache2::RequestRec();
use JSON::PP;
use JSON::MaybeXS;
use Data::DeepAccess qw(deep_get);
use Storable qw(dclone);
use Encode;
Expand Down Expand Up @@ -346,7 +346,7 @@ sub send_api_response ($request_ref) {
my $status_code = $request_ref->{api_response}{status_code} || $request_ref->{status_code} || "200";
delete $request_ref->{api_response}{status_code};

my $json = JSON::PP->new->allow_nonref->canonical->utf8->encode($request_ref->{api_response});
my $json = JSON::MaybeXS->new->allow_nonref->canonical->utf8->encode($request_ref->{api_response});

# add headers
# We need to send the header Access-Control-Allow-Credentials=true so that websites
Expand Down
2 changes: 1 addition & 1 deletion lib/ProductOpener/APITaxonomySuggestions.pm
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ sub taxonomy_suggestions_api ($request_ref) {
$matched_synonyms{$_->{tag}} = ucfirst($_->{matched_synonym});
}
$response_ref->{matched_synonyms} = \%matched_synonyms;
# Note: this does not seem to work with JSON::PP, even though the "canonical" option
# Note: this does not seem to work with JSON::MaybeXS, even though the "canonical" option
# should preserve the order of the keys of tied hashes.
# As JSON hashes are unordered, we will use the "suggestions" array on the client side to get the right order.
# It would have been nice to order the matched synonyms anyway, but it is not a huge issue.
Expand Down
2 changes: 1 addition & 1 deletion lib/ProductOpener/APITest.pm
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ use LWP::UserAgent;
use HTTP::CookieJar::LWP;
use HTTP::Request::Common;
use Encode;
use JSON::PP;
use JSON::MaybeXS;
use Carp qw/confess/;
use Clone qw/clone/;
use File::Tail;
Expand Down
2 changes: 1 addition & 1 deletion lib/ProductOpener/Data.pm
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ use experimental 'smartmatch';
use ProductOpener::Config qw/:all/;

use MongoDB;
use JSON::PP;
use JSON::MaybeXS;
use CGI ':cgi-lib';
use Log::Any qw($log);

Expand Down
14 changes: 7 additions & 7 deletions lib/ProductOpener/Display.pm
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ use DateTime::Locale;
use experimental 'smartmatch';
use MongoDB;
use Tie::IxHash;
use JSON::PP;
use JSON::MaybeXS;
use Text::CSV;
use XML::Simple;
use CLDR::Number;
Expand Down Expand Up @@ -226,9 +226,9 @@ my $uri_finder = URI::Find->new(

# Sort keys of JSON output
# $json has utf8 disabled: it encodes to Perl Unicode strings
my $json = JSON::PP->new->utf8(0)->allow_nonref->canonical;
my $json = JSON::MaybeXS->new->utf8(0)->allow_nonref->canonical;
# $json_utf8 has utf8 enabled: it encodes to UTF-8 bytes
my $json_utf8 = JSON::PP->new->utf8(1)->allow_nonref->canonical;
my $json_utf8 = JSON::MaybeXS->new->utf8(1)->allow_nonref->canonical;

=head1 VARIABLES
Expand Down Expand Up @@ -5321,7 +5321,7 @@ sub search_and_display_products ($request_ref, $query_ref, $sort_by, $limit, $pa
}
}

# tied hashes can't be encoded directly by JSON::PP, freeze the sort tied hash
# tied hashes can't be encoded directly by JSON::MaybeXS, freeze the sort tied hash
my $mongodb_query_ref = [
lc => $lc,
query => $query_ref,
Expand Down Expand Up @@ -6203,7 +6203,7 @@ sub display_scatter_plot ($graph_ref, $products_ref, $request_ref) {

# create data entry for series
defined $series{$seriesid} or $series{$seriesid} = '';
$series{$seriesid} .= JSON::PP->new->encode(\%data) . ',';
$series{$seriesid} .= JSON::MaybeXS->new->encode(\%data) . ',';
# count entries / series
defined $series_n{$seriesid} or $series_n{$seriesid} = 0;
$series_n{$seriesid}++;
Expand Down Expand Up @@ -11505,10 +11505,10 @@ sub search_and_analyze_recipes ($request_ref, $query_ref) {
if (single_param("debug")) {
$debug
.= "product: "
. JSON::PP->new->utf8->canonical->encode($product_ref)
. JSON::MaybeXS->new->utf8->canonical->encode($product_ref)
. "<br><br>\n\n"
. "recipe: "
. JSON::PP->new->utf8->canonical->encode($recipe_ref)
. JSON::MaybeXS->new->utf8->canonical->encode($recipe_ref)
. "<br><br><br>\n\n\n";
}
}
Expand Down
Loading

0 comments on commit c43455a

Please sign in to comment.