Bug 9367: Followup finalizing QA
authorMarcel de Rooy <m.de.rooy@rijksmuseum.nl>
Mon, 11 Mar 2013 11:13:29 +0000 (12:13 +0100)
committerJared Camins-Esakov <jcamins@cpbibliography.com>
Sat, 16 Mar 2013 15:49:43 +0000 (11:49 -0400)
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Keeping fetchrow close to its execute worked even better in GetReserveStatus.
Instead of returning undef, I return empty string.
I checked all calls; this value is mostly not checked for undef.
So we eliminate a lot of warnings in log.
Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com>
C4/Reserves.pm

index ded88c8..ba12cf5 100644 (file)
@@ -749,23 +749,26 @@ sub GetReserveStatus {
 
     my $dbh = C4::Context->dbh;
 
-    my ($sth, $found, $priority) = (undef, q{}, 0);
+    my ($sth, $found, $priority);
     if ( $itemnumber ) {
         $sth = $dbh->prepare("SELECT found, priority FROM reserves WHERE itemnumber = ? order by priority LIMIT 1");
         $sth->execute($itemnumber);
+        ($found, $priority) = $sth->fetchrow_array;
     }
 
     if ( $biblionumber and not defined $found and not defined $priority ) {
         $sth = $dbh->prepare("SELECT found, priority FROM reserves WHERE biblionumber = ? order by priority LIMIT 1");
         $sth->execute($biblionumber);
+        ($found, $priority) = $sth->fetchrow_array;
     }
-    ($found, $priority) = $sth->fetchrow_array;
 
-    return unless defined $found;
-    return 'Waiting'  if $found eq 'W' and $priority == 0;
-    return 'Finished' if $found eq 'F';
-    return 'Reserved' if $priority > 0;
-    return;
+    if(defined $found) {
+        return 'Waiting'  if $found eq 'W' and $priority == 0;
+        return 'Finished' if $found eq 'F';
+        return 'Reserved' if $priority > 0;
+    }
+    return '';
+    #empty string here will remove need for checking undef, or less log lines
 }
 
 =head2 CheckReserves