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;
}
-4
View File
@@ -620,10 +620,6 @@ if (defined('ABORT_AFTER_CONFIG')) {
require_once($CFG->libdir .'/setuplib.php'); // Functions that MUST be loaded first.
// TODO MDL-81933 Remove after Moodle 4.5 release.
require_once($CFG->libdir . '/classes/exception/moodle_exception.php'); // Required by some other legacy libraries.
require_once($CFG->libdir . '/classes/output/bootstrap_renderer.php'); // Required by some other legacy libraries.
// Load up standard libraries.
require_once($CFG->libdir .'/filterlib.php'); // Functions for filtering test as it is output.
require_once($CFG->libdir .'/ajax/ajaxlib.php'); // Functions for managing our use of JavaScript and YUI.