From e9f47d4fd8ee441df894ec34423d16b4e9ad6efe Mon Sep 17 00:00:00 2001
From: Demian Katz <demian.katz@villanova.edu>
Date: Fri, 2 Dec 2016 08:37:47 -0500
Subject: [PATCH] Smarter handling of unexpected Combined/SearchBox params.

---
 .../VuFind/src/VuFind/Controller/CombinedController.php  | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/module/VuFind/src/VuFind/Controller/CombinedController.php b/module/VuFind/src/VuFind/Controller/CombinedController.php
index 50832b8e8bf..8f7bb0a43f5 100644
--- a/module/VuFind/src/VuFind/Controller/CombinedController.php
+++ b/module/VuFind/src/VuFind/Controller/CombinedController.php
@@ -244,7 +244,14 @@ class CombinedController extends AbstractSearch
             $lookfor = $this->params()->fromQuery('lookfor');
             return $this->redirect()->toUrl($target . urlencode($lookfor));
         default:
-            throw new \Exception('Unexpected search type.');
+            // If parameters are completely missing, just redirect to home instead
+            // of throwing an error; this is possibly a misbehaving crawler that
+            // followed the SearchBox URL without passing any parameters.
+            if (empty($type) && empty($target)) {
+                return $this->redirect()->toRoute('home');
+            }
+            // If we have a weird value here, report it as an Exception:
+            throw new \Exception('Unexpected search type: "' . $type . '".');
         }
     }
 
-- 
GitLab