Merge branch 'MDL-82747-404' of https://github.com/andrewnicols/moodle into MOODLE_404_STABLE

This commit is contained in:
Jun Pataleta
2024-08-14 23:04:52 +08:00
5 changed files with 54 additions and 21 deletions
+3 -7
View File
@@ -177,6 +177,7 @@ $CFG->admin = array_pop($parts);
ini_set('include_path', $CFG->libdir.'/pear' . PATH_SEPARATOR . ini_get('include_path'));
require_once($CFG->libdir.'/classes/component.php');
require_once($CFG->libdir.'/classes/text.php');
require_once($CFG->libdir.'/classes/string_manager.php');
require_once($CFG->libdir.'/classes/string_manager_install.php');
@@ -192,13 +193,8 @@ require_once($CFG->libdir.'/adminlib.php');
require_once($CFG->libdir.'/componentlib.class.php');
require_once($CFG->dirroot.'/cache/lib.php');
// Register our classloader, in theory somebody might want to replace it to load other hacked core classes.
// Required because the database checks below lead to session interaction which is going to lead us to requiring autoloaded classes.
if (defined('COMPONENT_CLASSLOADER')) {
spl_autoload_register(COMPONENT_CLASSLOADER);
} else {
spl_autoload_register('core_component::classloader');
}
// Register our classloader.
\core_component::register_autoloader();
require($CFG->dirroot.'/version.php');
$CFG->target_release = $release;
+3 -8
View File
@@ -218,13 +218,9 @@ require_once($CFG->dirroot.'/cache/lib.php');
//the problem is that we need specific version of quickforms and hacked excel files :-(
ini_set('include_path', $CFG->libdir.'/pear' . PATH_SEPARATOR . ini_get('include_path'));
// Register our classloader, in theory somebody might want to replace it to load other hacked core classes.
// Required because the database checks below lead to session interaction which is going to lead us to requiring autoloaded classes.
if (defined('COMPONENT_CLASSLOADER')) {
spl_autoload_register(COMPONENT_CLASSLOADER);
} else {
spl_autoload_register('core_component::classloader');
}
// Register our classloader.
\core_component::register_autoloader();
require('version.php');
$CFG->target_release = $release;
@@ -653,4 +649,3 @@ echo '</div>';
install_print_footer($config);
die;
+39
View File
@@ -129,6 +129,45 @@ class core_component {
'Invoker' => 'lib/php-di/invoker/src',
];
/**
* An array containing files which are normally in a package's composer/autoload.files section.
*
* PHP does not provide a mechanism for automatically including the files that methods are in.
*
* The Composer autoloader includes all files in this section of the composer.json file during the instantiation of the loader.
*
* @var array<string>
*/
protected static $composerautoloadfiles = [
'lib/aws-sdk/src/functions.php',
'lib/guzzlehttp/guzzle/src/functions_include.php',
'lib/guzzlehttp/promises/src/functions_include.php',
'lib/jmespath/src/JmesPath.php',
'lib/php-di/php-di/src/functions.php',
'lib/ralouphi/getallheaders/src/getallheaders.php',
'lib/symfony/deprecation-contracts/function.php',
];
/**
* Register the Moodle class autoloader.
*/
public static function register_autoloader(): void {
if (defined('COMPONENT_CLASSLOADER')) {
spl_autoload_register(COMPONENT_CLASSLOADER);
} else {
spl_autoload_register([self::class, 'classloader']);
}
// Load any composer-driven autoload files.
// This is intended to mimic the behaviour of the standard Composer Autoloader.
foreach (static::$composerautoloadfiles as $file) {
$path = dirname(__DIR__, 2) . '/' . $file;
if (file_exists($path)) {
require_once($path);
}
}
}
/**
* Class loader for Frankenstyle named classes in standard locations.
* Frankenstyle namespaces are supported.
+2 -6
View File
@@ -620,12 +620,8 @@ if (!empty($_SERVER['HTTP_X_moz']) && $_SERVER['HTTP_X_moz'] === 'prefetch'){
//the problem is that we need specific version of quickforms and hacked excel files :-(
ini_set('include_path', $CFG->libdir.'/pear' . PATH_SEPARATOR . ini_get('include_path'));
// Register our classloader, in theory somebody might want to replace it to load other hacked core classes.
if (defined('COMPONENT_CLASSLOADER')) {
spl_autoload_register(COMPONENT_CLASSLOADER);
} else {
spl_autoload_register('core_component::classloader');
}
// Register our classloader.
\core_component::register_autoloader();
// Remember the default PHP timezone, we will need it later.
core_date::store_default_php_timezone();
+7
View File
@@ -1,6 +1,13 @@
This files describes API changes in core libraries and APIs,
information provided here is intended especially for developers.
=== 4.4.3 ===
* The Moodle autoloader should now be registered using `\core\component::register_autoloader` rather
than manually doing so in any exceptional location which requires it. It is not normally necessary
to include the autoloader manually, as it is registered automatically when the Moodle environment
is bootstrapped.
=== 4.4.2 ===
* The `\core\dataformat::get_format_instance` method is now public, and can be used to retrieve a writer instance for