From a3b03d3b45f165cc1431272eb5c0b85d85927302 Mon Sep 17 00:00:00 2001 From: Demian Katz <demian.katz@villanova.edu> Date: Fri, 1 Nov 2013 11:18:02 -0400 Subject: [PATCH] SwitchQuery should ignore ID-based queries. --- .../src/VuFind/Recommend/SwitchQuery.php | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/module/VuFind/src/VuFind/Recommend/SwitchQuery.php b/module/VuFind/src/VuFind/Recommend/SwitchQuery.php index 0b4e8907ee3..816f8012390 100644 --- a/module/VuFind/src/VuFind/Recommend/SwitchQuery.php +++ b/module/VuFind/src/VuFind/Recommend/SwitchQuery.php @@ -144,6 +144,11 @@ class SwitchQuery implements RecommendInterface // Get the query to manipulate: $query = $this->results->getParams()->getDisplayQuery(); + // If the query is of a type that should be skipped, go no further: + if ($this->queryShouldBeSkipped($query)) { + return; + } + // Perform all checks (based on naming convention): $methods = get_class_methods($this); $checks = array(); @@ -160,6 +165,24 @@ class SwitchQuery implements RecommendInterface } } + /** + * Should the query be ignored when making recommendations? + * + * @param string $query Query to check + * + * @return bool + */ + protected function queryShouldBeSkipped($query) + { + // If this is an ID list query, it was probably generated by New Items, + // Course Reserves, etc., and thus should not be further manipulated by + // the user. + if (substr($query, 0, 3) == 'id:') { + return true; + } + return false; + } + /** * Does the query contain lowercase boolean operators that should be uppercased? * -- GitLab