Skip to content
Snippets Groups Projects
Commit a3b03d3b authored by Demian Katz's avatar Demian Katz
Browse files

SwitchQuery should ignore ID-based queries.

parent 4ef0c84b
No related merge requests found
...@@ -144,6 +144,11 @@ class SwitchQuery implements RecommendInterface ...@@ -144,6 +144,11 @@ class SwitchQuery implements RecommendInterface
// Get the query to manipulate: // Get the query to manipulate:
$query = $this->results->getParams()->getDisplayQuery(); $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): // Perform all checks (based on naming convention):
$methods = get_class_methods($this); $methods = get_class_methods($this);
$checks = array(); $checks = array();
...@@ -160,6 +165,24 @@ class SwitchQuery implements RecommendInterface ...@@ -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? * Does the query contain lowercase boolean operators that should be uppercased?
* *
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment