MDL-62707 search: account for no matching courses when listing areas.

When limiting the list of courses during retrieval of the search areas
the user can access, make sure we have some contexts before looking
for blocks.
This commit is contained in:
Paul Holden
2020-12-04 09:43:07 +00:00
parent 329c04c1de
commit c19a18ecd4
2 changed files with 39 additions and 3 deletions
+2 -2
View File
@@ -823,8 +823,8 @@ class manager {
}
}
// Add all supported block contexts, in a single query for performance.
if (!empty($areasbylevel[CONTEXT_BLOCK])) {
// Add all supported block contexts for course contexts that user can access, in a single query for performance.
if (!empty($areasbylevel[CONTEXT_BLOCK]) && !empty($coursecontextids)) {
// Get list of all block types we care about.
$blocklist = [];
foreach ($areasbylevel[CONTEXT_BLOCK] as $areaid => $searchclass) {