Bug 20323: Fix batch patron modification tool
authorJosef Moravec <josef.moravec@gmail.com>
Fri, 2 Mar 2018 10:13:00 +0000 (10:13 +0000)
committerNick Clemens <nick@bywatersolutions.com>
Thu, 15 Mar 2018 08:26:10 +0000 (08:26 +0000)
Test plan:
1) Go to Tools -> Batch patrons modification
2) Select some patrons and try to change any field
--> without patch - it exploads with log:
Can't call method "category" on unblessed reference at /home/vagrant/kohaclone/tools/modborrowers.pl
--> with patch - the modification is properly made

Signed-off-by: Roch D'Amour <roch.damour@inlibro.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

tools/modborrowers.pl

index 7e51a5a..586ae53 100755 (executable)
@@ -339,8 +339,9 @@ if ( $op eq 'do' ) {
     for my $borrowernumber ( @borrowernumbers ) {
         my $patron = Koha::Patrons->find( $borrowernumber );
         if ( $patron ) {
+            my $category_description = $patron->category->description;
             $patron = $patron->unblessed;
-            $patron->{category_description} = $patron->category->description;
+            $patron->{category_description} = $category_description;
             $patron->{patron_attributes} = C4::Members::Attributes::GetBorrowerAttributes( $patron->{borrowernumber} );
             $max_nb_attr = scalar( @{ $patron->{patron_attributes} } )
                 if scalar( @{ $patron->{patron_attributes} } ) > $max_nb_attr;