From 439537b295cb416a05f89300c06cdf2493033e54 Mon Sep 17 00:00:00 2001 From: Petro Vashchuk Date: Wed, 15 Dec 2021 16:49:15 +0200 Subject: [PATCH] Bug 29684: fix warn about not found file js/locale_data.js Value of 'lang' unexpectedly was set to 'default', to prevent it, the feature was added to detect 'lang' getting overlaid in template and prevent + warn the developer about it. To reproduce (memberentry.pl): 1) Head over to the patron details page, press edit button to open the memberentry.pl page. 2) The error message should have appeared in your log file about "File not found : default/js/locale_data.js". 3) Apply the patch. 4) Open the edit page again, ensure that the new error massage like that didn't appear. To reproduce (paycollect.pl): 1) Prepare or use some existing patron with outstanding fines, go to the accounting section and open page where you make payment towards all fines. 2) The error message should have appeared in your log file about "File not found : default/js/locale_data.js". 3) Apply the patch. 4) Open the edit page again, ensure that the new error massage like that didn't appear. Signed-off-by: Tomas Cohen Arazi --- C4/Templates.pm | 7 +++++++ members/memberentry.pl | 4 ++++ members/paycollect.pl | 3 +++ 3 files changed, 14 insertions(+) diff --git a/C4/Templates.pm b/C4/Templates.pm index d41c9b534e..0d1be549d5 100644 --- a/C4/Templates.pm +++ b/C4/Templates.pm @@ -113,6 +113,13 @@ sub output { $vars->{opaclayoutstylesheet} = C4::Context->preference('opaclayoutstylesheet'); + + if(exists $self->{VARS}{lang}) { + warn "Preventing \$template->lang='" . ($self->{vars}{lang}//'-undef-') + . "' to be overwritten by template->{VARS}{lang}='" . ($self->{VARS}{lang}//'-undef-') . "'"; + delete $self->{VARS}{lang}; + } + # add variables set via param to $vars for processing $vars = { %$vars, %{ $self->{VARS} } }; diff --git a/members/memberentry.pl b/members/memberentry.pl index 38f2a2b149..b4fae040cb 100755 --- a/members/memberentry.pl +++ b/members/memberentry.pl @@ -813,6 +813,10 @@ if (C4::Context->preference('EnhancedMessagingPreferences')) { } $template->param( "show_guarantor" => ( $category_type =~ /A|I|S|X/ ) ? 0 : 1 ); # associate with step to know where you are + +# we should remove 'lang' from borrower data otherwise it overlays Template's lang variable: +delete $data{lang}; + $template->param(%data); $template->param( "step_$step" => 1) if $step; # associate with step to know where u are $template->param( step => $step ) if $step; # associate with step to know where u are diff --git a/members/paycollect.pl b/members/paycollect.pl index d5cbd60bfc..a6eab11ab9 100755 --- a/members/paycollect.pl +++ b/members/paycollect.pl @@ -239,6 +239,9 @@ if ( $total_paid and $total_paid ne '0.00' ) { $total_paid = '0.00'; #TODO not right with pay_individual } +# we should remove 'lang' from borrower data otherwise it overlays Template's lang variable: +delete $borrower->{lang}; + $template->param(%$borrower); if ( $input->param('error_over') ) { -- 2.32.0