Commit b0c0d612 authored by Jake Dallimore's avatar Jake Dallimore
Browse files

Merge branch 'MDL-69726' of git://github.com/aolley/moodle

parents 4f3d5dfc 5650b7e3
......@@ -281,7 +281,7 @@ class raw_event_retrieval_strategy implements raw_event_retrieval_strategy_inter
$unionstartquery = "SELECT modulename, instance, eventtype, priority
FROM {event} ev
WHERE ";
$subqueryunion = $unionstartquery . implode(" UNION $unionstartquery ", $subqueryconditions);
$subqueryunion = '('.$unionstartquery . implode(" UNION $unionstartquery ", $subqueryconditions).')';
} else {
$subqueryunion = '{event}';
}
......@@ -296,7 +296,7 @@ class raw_event_retrieval_strategy implements raw_event_retrieval_strategy_inter
ev.instance,
ev.eventtype,
MIN(ev.priority) as priority
FROM ($subqueryunion) ev
FROM $subqueryunion ev
GROUP BY ev.modulename, ev.instance, ev.eventtype";
// Build the main query.
......
......@@ -447,4 +447,15 @@ class core_calendar_raw_event_retrieval_strategy_testcase extends advanced_testc
array_column($events, 'name'),
'', 0.0, 10, true);
}
/**
* Test retrieval strategy with empty filters.
* This covers a edge case not covered elsewhere to ensure its SQL is cross
* db compatible. The test is ensuring we don't get a DML Exception with
* the filters setup this way.
*/
public function test_get_raw_events_with_empty_user_and_category_lists() {
$retrievalstrategy = new raw_event_retrieval_strategy;
$retrievalstrategy->get_raw_events([], null, null, []);
}
}
Supports Markdown
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