MDL-82156 core: Check that key classes are present for classloader

This commit is contained in:
Andrew Nicols
2024-06-14 12:28:55 +08:00
parent ca985c79c6
commit 434c191ff3
2 changed files with 18 additions and 4 deletions
+18
View File
@@ -383,6 +383,24 @@ class core_component {
return false;
}
// Check for key classes which block access to the upgrade in some way.
// Note: This list should be kept _extremely_ minimal and generally
// when adding a newly discovered classes older ones should be removed.
// Always keep moodle_exception in place.
$keyclasses = [
\core\exception\moodle_exception::class,
\core\output\bootstrap_renderer::class,
];
foreach ($keyclasses as $classname) {
if (!array_key_exists($classname, $cache['classmap'])) {
// The cache is missing some key classes. This is likely before the upgrade has run.
error_log(
"The '{$classname}' class was not found in the component class cache. Resetting the classmap.",
);
return false;
}
}
return true;
}