Avoid server-error on barcode search when barcode not found
authorBill Erickson <berick@esilibrary.com>
Thu, 28 Jul 2011 18:31:31 +0000 (14:31 -0400)
committerBill Erickson <berick@esilibrary.com>
Thu, 28 Jul 2011 18:31:31 +0000 (14:31 -0400)
Signed-off-by: Bill Erickson <berick@esilibrary.com>

Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm
Open-ILS/web/templates/default/opac/results.tt2

index f9594b3..a1aa2e6 100644 (file)
@@ -237,16 +237,22 @@ sub item_barcode_shortcut {
         )->gather(1);
 
         if (ref $rec_ids ne 'ARRAY') {
-            if (defined $U->event_code($rec_ids)) {
-                $self->apache->log->warn(
-                    "$method returned event: " . $U->event_code($rec_ids)
-                );
+
+            if($U->event_equals($rec_ids, 'ASSET_COPY_NOT_FOUND')) {
+                $rec_ids = [];
+
             } else {
-                $self->apache->log->warn(
-                    "$method returned something unexpected: $rec_ids"
-                );
+                if (defined $U->event_code($rec_ids)) {
+                    $self->apache->log->warn(
+                        "$method returned event: " . $U->event_code($rec_ids)
+                    );
+                } else {
+                    $self->apache->log->warn(
+                        "$method returned something unexpected: $rec_ids"
+                    );
+                }
+                return Apache2::Const::HTTP_INTERNAL_SERVER_ERROR;
             }
-            return Apache2::Const::HTTP_INTERNAL_SERVER_ERROR;
         }
 
         my ($facets, @data) = $self->get_records_and_facets(
index 139cf5f..9b2d242 100644 (file)
@@ -11,7 +11,7 @@
     END;
 
     page = CGI.param('page') || 0;
-    page_count = POSIX.ceil(ctx.hit_count / ctx.page_size);
+    page_count = ctx.page_size == 0 ? 1 : POSIX.ceil(ctx.hit_count / ctx.page_size);
 %]
     <form action="[% ctx.opac_root %]/results" method="GET">
     <div id="search-wrapper">