From 66845e52301a576f8795829978c6f87fbe1515c9 Mon Sep 17 00:00:00 2001 From: Erik Huelsmann Date: Fri, 6 Oct 2023 23:19:25 +0200 Subject: [PATCH] Work around Locale::CLDR::Locales::* loading 'bignum' Loading 'bignum' causes $Math::BigInt::upgrade and $Math::BigFloat::downgrade to be overwritten. However, we want to make sure these values stay as they are set by LedgerSMB::PGNumber (which is: no downgrading!) This is necessary for Perl 5.36+ compatibility. --- lib/LedgerSMB.pm | 2 ++ lib/LedgerSMB/Database/Config.pm | 8 ++++++-- lib/LedgerSMB/I18N.pm | 6 +++++- lib/LedgerSMB/Scripts/user.pm | 6 +++++- 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/lib/LedgerSMB.pm b/lib/LedgerSMB.pm index 4f660d1fe7c..b8a87f4e548 100644 --- a/lib/LedgerSMB.pm +++ b/lib/LedgerSMB.pm @@ -625,6 +625,8 @@ sub enabled_languages { sub enabled_countries { my ($self) = @_; + local $Math::BigInt::upgrade; + local $Math::BigFloat::downgrade; my $regions = Locale::CLDR->new($self->{_user}->{language})->all_regions; return [ map { diff --git a/lib/LedgerSMB/Database/Config.pm b/lib/LedgerSMB/Database/Config.pm index 1643b749c20..f17f3e0b943 100644 --- a/lib/LedgerSMB/Database/Config.pm +++ b/lib/LedgerSMB/Database/Config.pm @@ -125,8 +125,12 @@ sub charts_of_accounts { ###TODO: Define a parameter to the SQL directory!! my $basedir = File::Spec->catfile('.', 'locale', 'coa'); my $countries = _list_directory($basedir); - my %regions = %{Locale::CLDR->new($self->language) - ->all_regions}; + my $cldr = do { + local $Math::BigInt::upgrade = undef; + local $Math::BigFloat::downgrade = undef; + Locale::CLDR->new($self->language); + }; + my %regions = %{$cldr->all_regions}; return { map { diff --git a/lib/LedgerSMB/I18N.pm b/lib/LedgerSMB/I18N.pm index 54869a8e9de..23a5e2768d1 100644 --- a/lib/LedgerSMB/I18N.pm +++ b/lib/LedgerSMB/I18N.pm @@ -127,7 +127,11 @@ Get a country localized list to allow user selection sub get_country_list { my $language = shift; - my %regions = Locale::CLDR->new($language)->all_regions->%*; + my %regions = do { + local $Math::BigInt::upgrade = undef; + local $Math::BigFloat::downgrade = undef; + Locale::CLDR->new($language)->all_regions->%* + }; return [ sort { $a->{text} cmp $b->{text} } map { +{ value => uc($_), diff --git a/lib/LedgerSMB/Scripts/user.pm b/lib/LedgerSMB/Scripts/user.pm index dc7b80c1bff..af40722d7a2 100644 --- a/lib/LedgerSMB/Scripts/user.pm +++ b/lib/LedgerSMB/Scripts/user.pm @@ -132,7 +132,11 @@ sub preference_screen { dateformats => $dateformats, language_codes => _language_options( $request, - Locale::CLDR->new( $prefs->{language} )), + do { + local $Math::BigInt::upgrade = undef; + local $Math::BigFloat::downgrade = undef; + Locale::CLDR->new( $prefs->{language} ); + }), login => $login, numberformats => $numberformats, password_expires => {