Created attachment 136374 [details] [review] Bug 30997: Fix "CGI::param called in list context" warning in detail.pl CGI param found1 should be explicitly scalar, or else error log gets flooded with this warning: CGI::param called in list context from /usr/share/koha/intranet/cgi-bin/catalogue/detail.pl line 622 This patch fixes it by working with it in a scalar context. The functionality still remains the same but warning doesn't flood error log. To reproduce: 1. Open any biblio (details.pl) page. 2. Check the error log and find the upper mentioned warning, check the timestamp to ensure that it was added when you loaded the page. 3. Apply the patch. 4. Load the page again, ensure that the same warning doesn't get added to the log file again.
Created attachment 136377 [details] [review] Bug 30997: Fix "CGI::param called in list context" warning in detail.pl CGI param found1 should be explicitly scalar, or else error log gets flooded with this warning: CGI::param called in list context from /usr/share/koha/intranet/cgi-bin/catalogue/detail.pl line 622 This patch fixes it by working with it in a scalar context. The functionality still remains the same but warning doesn't flood error log. To reproduce: 1. Open any biblio (details.pl) page. 2. Check the error log and find the upper mentioned warning, check the timestamp to ensure that it was added when you loaded the page. 3. Apply the patch. 4. Load the page again, ensure that the same warning doesn't get added to the log file again. Signed-off-by: David Nind <david@davidnind.com>
Testing notes (using koha-testing-docker): 1. For me, the error only appeared twice in the logs for the first two records accessed. After a flush_memcached and restart_all it appears again twice. 2. Search/records used: either perl or cat, then paged through several results. 3. Also tried closing browser (set so cache is cleared and history isn't remembered), but required a restart_all for the error to start appearing in the logs again.
Created attachment 136386 [details] [review] Bug 30997: Fix "CGI::param called in list context" warning in detail.pl CGI param found1 should be explicitly scalar, or else error log gets flooded with this warning: CGI::param called in list context from /usr/share/koha/intranet/cgi-bin/catalogue/detail.pl line 622 This patch fixes it by working with it in a scalar context. The functionality still remains the same but warning doesn't flood error log. To reproduce: 1. Open any biblio (details.pl) page. 2. Check the error log and find the upper mentioned warning, check the timestamp to ensure that it was added when you loaded the page. 3. Apply the patch. 4. Load the page again, ensure that the same warning doesn't get added to the log file again. Signed-off-by: David Nind <david@davidnind.com> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
sidenote to David: authors of CGI.pm decided to "warn only once" that's why Plack restart helps: it starts from again "$LIST_CONTEXT_WARN == 1". from CGI.pm source in sub param: if ( wantarray && $LIST_CONTEXT_WARN == 1 ) { my ( $package, $filename, $line ) = caller; if ( $package ne 'CGI' ) { $LIST_CONTEXT_WARN++; # only warn once warn "CGI::param called in list context from $filename line $line, this can lead to vulnerabilities. " . 'See the warning in "Fetching the value or values of a single named parameter"'; } } Petro: Maybe the commit explanation might be expanded with the note "on freshly started plack because this wards suppressed later by CGI.pm"
(In reply to Andrew Nugged from comment #5) > sidenote to David: > > authors of CGI.pm decided to "warn only once" that's why Plack restart > helps: it starts from again "$LIST_CONTEXT_WARN == 1". Thanks Andrew! That explains things. David
Pushed to master for 22.11. Nice work everyone, thanks!
Backported to 22.05.x for 22.05.03
pushed to 21.11.x for 21.11.11
Not backported to oldoldstable (21.05.x). Feel free to ask if it's needed. Nothing to document, marking resolved.