-
Notifications
You must be signed in to change notification settings - Fork 17
Open
Description
When considering the boosted area settings and logic, the query logic in query.php/get_query() function utilises the PHP array_merge function to combine multiple boosted areas, however this function has been used incorrectly by not assigning the result of the merge back to the query data (i.e. it has been used as if the array being merged is passed by reference).
This issue can be recreated/checked as follows:
- Enable query logging
- Confgure multiple boosted areas
- Run a search, inspect the query - this will show only a single boosted area in the
shouldmatch array - Apply the fix below
- Run the same search, inspect the query - the
shouldmatch array will contain multiple elements, i.e. for each boosted area
This issue occurrs in 2 places:
if ($filters->context->contextlevel !== CONTEXT_COURSE) {
// If it's a block or activity, also add a boost for the specific context id.
$contextid = $filters->context->id;
$contextboost = $this->consruct_location_boosting('contextid', $contextid, self::CONTEXT_BOOST);
if (count($query['query']['bool']['should'])) {
array_merge ($query['query']['bool']['should'], $contextboost);
} else {
$query['query']['bool']['should'] = $contextboost;
}
}if ($boostedareas) {
$boosting = $this->consruct_boosting($boostedareas);
if (count($query['query']['bool']['should'])) {
array_merge ($query['query']['bool']['should'], $boosting);
} else {
$query['query']['bool']['should'] = $boosting;
}
}The fix is to simply change the affected lines to:
$query['query']['bool']['should'] = array_merge ($query['query']['bool']['should'], $contextboost);$query['query']['bool']['should'] = array_merge ($query['query']['bool']['should'], $boosting);Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels