MDL-83757 core: Force DI to use global DB instead of scoped

This commit is contained in:
Andrew Nicols 2025-02-05 20:07:42 +08:00
parent 07881a5772
commit e17dd3bf62
No known key found for this signature in database
GPG Key ID: 6D1E3157C8CFBF14

View File

@ -84,7 +84,7 @@ class di {
* @return ContainerInterface
*/
protected static function create_container(): ContainerInterface {
global $CFG, $DB;
global $CFG;
// PHP Does not support function autoloading. We must manually include the file.
require_once("{$CFG->libdir}/php-di/php-di/src/functions.php");
@ -113,7 +113,11 @@ class di {
\core\hook\manager::class => $hookmanager,
// The database.
\moodle_database::class => $DB,
\moodle_database::class => function(): \moodle_database {
global $DB;
return $DB;
},
// The string manager.
\core_string_manager::class => fn() => get_string_manager(),