Always return [] when CStoreEditor search calls fail for any reason. user/jason@mvlc.org/CStoreEditor_undef_search_fix
authorJason Stephenson <jstephenson@mvlc.org>
Tue, 26 Jul 2011 19:32:58 +0000 (15:32 -0400)
committerJason Stephenson <jstephenson@mvlc.org>
Tue, 26 Jul 2011 19:34:06 +0000 (15:34 -0400)
Signed-off-by: Jason Stephenson <jstephenson@mvlc.org>
Open-ILS/src/perlmods/lib/OpenILS/Utils/CStoreEditor.pm

index 03237ca..f2d3c50 100644 (file)
@@ -730,7 +730,10 @@ sub runmethod {
                my $e = $self->_checkperm($type, $a, $$options{permorg});
                if($e) {
                        $self->event($e);
-                       return undef;
+                        # Per method comment, search always returns []
+                        # on failure. Much other code depends on that
+                        # behavior.
+                       return ($action eq 'search') ? [] : undef;
                }
        }
 
@@ -759,10 +762,16 @@ sub runmethod {
                        $self->event( 
                                OpenILS::Event->new( 'DATABASE_QUERY_FAILED', 
                                        payload => $arg, debug => "$err" ));
-                       return undef;
+                        # Per method comment, search always returns []
+                        # on failure. Much other code depends on that
+                        # behavior.
+                       return ($action eq 'search') ? [] : undef;
                }
 
-               return undef;
+                # Per method comment, search always returns []
+                # on failure. Much other code depends on that
+                # behavior.
+                return ($action eq 'search') ? [] : undef;
        }
 
        if( $action eq 'create' and $obj == 0 ) {
@@ -777,7 +786,10 @@ sub runmethod {
                $self->event( 
                        OpenILS::Event->new( 'DATABASE_QUERY_FAILED', 
                                payload => $arg, debug => "$err" ));
-               return undef;
+                # Per method comment, search always returns []
+                # on failure. Much other code depends on that
+                # behavior.
+                return ($action eq 'search') ? [] : undef;
        }
 
        if( $action eq 'search' ) {