Steps to recreate:
1) make sure $hascapability = $cache->get_many($keys); gets an empty array.
2) Assign a user to Site Administrator
3) Navigate to Course and category management page.
Expected result: the page is shown.
Actual result: the user is redirected to course/index.php?categoryid=1
Analysis:
A dig unearthed the function has_capability_on_any($capabilities)
in the file course/classes/category.php
which starts with checking the cache for the capabilities.
If the cache fetch fails, $cache->get_many($keys) returns an empty array.
This forces $needtoload to remain false, because an empty array isn't iterable.
Suggest the following solution:
++
diff --git a/course/classes/category.php b/course/classes/category.php
index 86b6abb17ad..b1abf985cbd 100644
— a/course/classes/category.php
+++ b/course/classes/category.php
@@ -1456,6 +1456,9 @@ class core_course_category implements renderable, cacheable_object, IteratorAggr
$cache = cache::make('core', 'coursecat');
$hascapability = $cache->get_many($keys);
$needtoload = false;
+ if (empty($hascapability))
foreach ($hascapability as $capability) {
if ($capability === '1') {
return true;
- will be (partly) resolved by
-
MDL-84315 Regression caused by MDL-75864 fix
-
- Open
-