From 81bb6761a23bb0c68aee2bdc43a5b353b7f76157 Mon Sep 17 00:00:00 2001 From: Petro Vashchuk Date: Thu, 9 Dec 2021 15:47:07 +0200 Subject: [PATCH] Bug 29669: fix uninitialized value warnings when XSLTParse4Display is called Wrong key 'xsl_filename' is present in opac-tags.pl and shelves.pl (the only places where it is used in the code even) instead of 'xsl_syspref' that is actually used and this is the cause of those warnings. Also added honeypot to check if other calls in same way happens. Honeypot probably not needed, review when QA in the Community. To reproduce (shelves.pl): 1) Prepare some test list with items or use existing one. 2) Go to the lists page (koha/virtualshelves/shelves.pl), notice multitude of new warnings in the "intranet-error.log" log file that mostly have to do with "Use of uninitialized value $xslsyspref". 3) Apply the patch. 4) Go back to same page and check it again, warns like that should not appear in the log file anymore. To reproduce (opac-tags.pl): 1) Go to the "my tags" page in OPAC and open "tag cloud". 2) Notice a bunch of new warnings in the log file that mostly have to do with "Use of uninitialized value $xslsyspref". 3) Apply the patch. 4) Reload the page and check the log file again. Signed-off-by: Jonathan Druart Signed-off-by: Marcel de Rooy Signed-off-by: Fridolin Somers --- C4/XSLT.pm | 3 +++ opac/opac-tags.pl | 2 +- virtualshelves/shelves.pl | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/C4/XSLT.pm b/C4/XSLT.pm index 125f887cb0..f69f9e72a3 100644 --- a/C4/XSLT.pm +++ b/C4/XSLT.pm @@ -251,6 +251,9 @@ sub XSLTParse4Display { my $variables = $params->{xslt_variables}; my $items_rs = $params->{items_rs}; + die "Mandatory \$params->{xsl_syspref} was not provided, called with biblionumber $params->{biblionumber}" + if not defined $params->{xsl_syspref}; + my $xslfilename = get_xsl_filename( $xslsyspref); # grab the XML, run it through our stylesheet, push it out to the browser diff --git a/opac/opac-tags.pl b/opac/opac-tags.pl index 63169e812a..515f4ccd2e 100755 --- a/opac/opac-tags.pl +++ b/opac/opac-tags.pl @@ -292,7 +292,7 @@ if ($loggedinuser) { { biblionumber => $tag->{biblionumber}, record => $record, - xsl_filename => 'OPACXSLTResultsDisplay', + xsl_syspref => 'OPACXSLTResultsDisplay', fix_amps => 1, hidden_items => $hidden_items, xslt_variables => $variables diff --git a/virtualshelves/shelves.pl b/virtualshelves/shelves.pl index d1ce868e4b..2cc09766cb 100755 --- a/virtualshelves/shelves.pl +++ b/virtualshelves/shelves.pl @@ -268,7 +268,7 @@ if ( $op eq 'view' ) { { biblionumber => $biblionumber, record => $record, - xsl_filename => "XSLTListsDisplay", + xsl_syspref => 'XSLTListsDisplay', fix_amps => 1, } ); -- 2.39.5