Koha/svc/members/add_to_list
Tomas Cohen Arazi 1570af154f Bug 29771: Remove trivial cases
I squashed the patches because they are too trivial to have a test plan.
Or it is too much work to write the test plan for such trivial cases. I
leave the original commit messages just in case.

Generally, this are all cases in which CGI::param is being called in a
trivially identifiable _list context_. i.e. they are assigned to a
@variable.

I left one case out on purpose: admin/auth_subfields_structure.pl

Paul introduced this:

my @kohafield = ''.$input->param('kohafield');
and then:
my $kohafield = $kohafield[$i];

My intuition says it is forcing scalar context on the first assignment
so the list contains a single element and then inside the loop some
$kohafield assignments should lead to undef, and even warnings. I leave
it for a separate patch because it is not that easy testable and is a
sensible area.

Bug 29771: Remove warning from  acqui/finishreceive.pl

This patch removes a warning that shows when receiving.

To test:
1. Do the acq workflow up to the receive step.
2. Once you choose the items and click on Finish
=> FAIL: There's a warning in the logs
3. Revert receipt
4. Apply this patch
5. Receive
=> SUCCESS: No more warnings
6. Sign off :-D

Bug 29771: Remove warning from svc/members/add_to_list

To test:
1. Run:
   $ tail -f /var/log/koha/kohadev/*-error.log
2. Generate a patron list
3. Perform a patron search that gives you a few
4. Select some, and choose to add them to the list
=> FAIL: The logs show the infamous warn:
CGI::param called in list context from /kohadevbox/koha/svc/members/add_to_list
5. Apply this patch
6. Restart plack and repeat 4
=> SUCCESS: No warn!
7. Sign off :-D

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
2022-03-08 23:03:34 -10:00

63 lines
1.9 KiB
Perl
Executable file

#!/usr/bin/perl
# Copyright 2013 BibLibre
#
# This file is part of Koha
#
# Koha is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# Koha is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Koha; if not, see <http://www.gnu.org/licenses>.
use Modern::Perl;
use CGI;
use C4::Auth qw( check_cookie_auth );
use JSON qw( to_json );
use Koha::List::Patron qw( AddPatronList GetPatronLists AddPatronsToList );
my $input = CGI->new;
my ( $auth_status ) = check_cookie_auth(
$input->cookie('CGISESSID'),
{ tools => 'manage_patron_lists' },
);
exit 0 if $auth_status ne "ok";
my $add_to_patron_list = $input->param('add_to_patron_list');
my $new_patron_list = $input->param('new_patron_list');
my @borrowernumbers = $input->multi_param('borrowernumbers[]');
my $response;
if ($add_to_patron_list) {
my $patron_list = [];
if ( $add_to_patron_list eq 'new' ) {
$patron_list = AddPatronList( { name => $new_patron_list } );
}
else {
$patron_list =
[ GetPatronLists( { patron_list_id => $add_to_patron_list } ) ]->[0];
}
my @patrons_added_to_list = AddPatronsToList( { list => $patron_list, borrowernumbers => \@borrowernumbers } );
$response->{patron_list} = { patron_list_id => $patron_list->patron_list_id, name => $patron_list->name };
$response->{patrons_added_to_list} = scalar( @patrons_added_to_list );
}
binmode STDOUT, ":encoding(UTF-8)";
print $input->header(
-type => 'application/json',
-charset => 'UTF-8'
);
print to_json( $response );