Bug 14117: Silence warnings t/SearchPazPar2.t
[koha.git] / C4 / CourseReserves.pm
index 12b6375..7e160d0 100644 (file)
@@ -2,18 +2,18 @@ package C4::CourseReserves;
 
 # 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 2 of the License, or (at your option) any later
-# version.
+# 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.
+# 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, write to the Free Software Foundation, Inc., 59 Temple Place,
-# Suite 330, Boston, MA  02111-1307 USA
+# 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;
 
@@ -46,7 +46,7 @@ BEGIN {
 
       &SearchCourses
 
-      &GetItemReservesInfo
+      &GetItemCourseReservesInfo
     );
     %EXPORT_TAGS = ( 'all' => \@EXPORT_OK );
 
@@ -568,7 +568,7 @@ sub _UpdateCourseItem {
             $mod_params{$_} = $params{$_};
         }
     }
-    ModItem( \%mod_params, undef, $course_item->{'itemnumber'} );
+    ModItem( \%mod_params, undef, $course_item->{'itemnumber'} ) if %mod_params;
 
     ## Update fields that didn't have an original value, but now do
     ## We must save the original value in course_items, and also
@@ -583,7 +583,7 @@ sub _UpdateCourseItem {
         }
     }
     _ModStoredFields( 'ci_id' => $params{'ci_id'}, %mod_params_old );
-    ModItem( \%mod_params_new, undef, $course_item->{'itemnumber'} );
+    ModItem( \%mod_params_new, undef, $course_item->{'itemnumber'} ) if %mod_params_new;
 
 }
 
@@ -648,7 +648,7 @@ sub _RevertFields {
             }
         }
     }
-    ModItem( $mod_item_params, undef, $course_item->{'itemnumber'} );
+    ModItem( $mod_item_params, undef, $course_item->{'itemnumber'} ) if $mod_item_params && %$mod_item_params;
 
     my $query = "UPDATE course_items SET " . join( ',', map { "$_=NULL" } @fields_to_null ) . " WHERE ci_id = ?";
 
@@ -677,7 +677,7 @@ sub _SwapAllFields {
         }
     }
 
-    ModItem( \%course_item_fields, undef, $course_item->{'itemnumber'} );
+    ModItem( \%course_item_fields, undef, $course_item->{'itemnumber'} ) if %course_item_fields;
     _ModStoredFields( %item_fields, ci_id => $ci_id );
 }
 
@@ -934,14 +934,14 @@ sub DelCourseReserve {
 
 =head2 GetReservesInfo
 
-    my $arrayref = GetItemReservesInfo( itemnumber => $itemnumber );
+    my $arrayref = GetItemCourseReservesInfo( itemnumber => $itemnumber );
 
     For a given item, returns an arrayref of reserves hashrefs,
     with a course hashref under the key 'course'
 
 =cut
 
-sub GetItemReservesInfo {
+sub GetItemCourseReservesInfo {
     my (%params) = @_;
     warn identify_myself(%params) if $DEBUG;
 
@@ -1052,6 +1052,7 @@ sub SearchCourses {
         GROUP BY c.course_id
     ";
 
+    $term //= '';
     $term   = "%$term%";
     @params = ($term) x 10;