Skip to content

Commit 60d8671

Browse files
committedJun 10, 2024
MDL-81919 core: Prioritise autoloader in install
1 parent a128312 commit 60d8671

File tree

3 files changed

+25
-25
lines changed

3 files changed

+25
-25
lines changed
 

‎admin/cli/install.php

+12-10
Original file line numberDiff line numberDiff line change
@@ -172,11 +172,21 @@
172172
$parts = explode('/', str_replace('\\', '/', dirname(__DIR__)));
173173
$CFG->admin = array_pop($parts);
174174

175-
//point pear include path to moodles lib/pear so that includes and requires will search there for files before anywhere else
176-
//the problem is that we need specific version of quickforms and hacked excel files :-(
175+
// Point pear include path to moodles lib/pear so that includes and requires will search there for files before anywhere else
176+
// the problem is that we need specific version of quickforms and hacked excel files :-(.
177177
ini_set('include_path', $CFG->libdir.'/pear' . PATH_SEPARATOR . ini_get('include_path'));
178178

179+
// The core_component class can be used in any scripts, it does not need anything else.
179180
require_once($CFG->libdir.'/classes/component.php');
181+
182+
// Register our classloader, in theory somebody might want to replace it to load other hacked core classes.
183+
// Required because the database checks below lead to session interaction which is going to lead us to requiring autoloaded classes.
184+
if (defined('COMPONENT_CLASSLOADER')) {
185+
spl_autoload_register(COMPONENT_CLASSLOADER);
186+
} else {
187+
spl_autoload_register('core_component::classloader');
188+
}
189+
180190
require_once($CFG->libdir.'/classes/text.php');
181191
require_once($CFG->libdir.'/classes/string_manager.php');
182192
require_once($CFG->libdir.'/classes/string_manager_install.php');
@@ -192,14 +202,6 @@
192202
require_once($CFG->libdir.'/componentlib.class.php');
193203
require_once($CFG->dirroot.'/cache/lib.php');
194204

195-
// Register our classloader, in theory somebody might want to replace it to load other hacked core classes.
196-
// Required because the database checks below lead to session interaction which is going to lead us to requiring autoloaded classes.
197-
if (defined('COMPONENT_CLASSLOADER')) {
198-
spl_autoload_register(COMPONENT_CLASSLOADER);
199-
} else {
200-
spl_autoload_register('core_component::classloader');
201-
}
202-
203205
require($CFG->dirroot.'/version.php');
204206
$CFG->target_release = $release;
205207

‎install.php

+12-14
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,18 @@
198198
}
199199
}
200200

201-
// Continue with lib loading
201+
// Point pear include path to moodles lib/pear so that includes and requires will search there for files before anywhere else
202+
// the problem is that we need specific version of quickforms and hacked excel files :-(.
203+
ini_set('include_path', $CFG->libdir.'/pear' . PATH_SEPARATOR . ini_get('include_path'));
204+
205+
// Register our classloader, in theory somebody might want to replace it to load other hacked core classes.
206+
if (defined('COMPONENT_CLASSLOADER')) {
207+
spl_autoload_register(COMPONENT_CLASSLOADER);
208+
} else {
209+
spl_autoload_register('core_component::classloader');
210+
}
211+
212+
// Continue with lib loading.
202213
require_once($CFG->libdir.'/classes/text.php');
203214
require_once($CFG->libdir.'/classes/string_manager.php');
204215
require_once($CFG->libdir.'/classes/string_manager_install.php');
@@ -214,18 +225,6 @@
214225
require_once($CFG->libdir.'/componentlib.class.php');
215226
require_once($CFG->dirroot.'/cache/lib.php');
216227

217-
//point pear include path to moodles lib/pear so that includes and requires will search there for files before anywhere else
218-
//the problem is that we need specific version of quickforms and hacked excel files :-(
219-
ini_set('include_path', $CFG->libdir.'/pear' . PATH_SEPARATOR . ini_get('include_path'));
220-
221-
// Register our classloader, in theory somebody might want to replace it to load other hacked core classes.
222-
// Required because the database checks below lead to session interaction which is going to lead us to requiring autoloaded classes.
223-
if (defined('COMPONENT_CLASSLOADER')) {
224-
spl_autoload_register(COMPONENT_CLASSLOADER);
225-
} else {
226-
spl_autoload_register('core_component::classloader');
227-
}
228-
229228
require('version.php');
230229
$CFG->target_release = $release;
231230

@@ -653,4 +652,3 @@
653652

654653
install_print_footer($config);
655654
die;
656-

‎lib/setup.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@
434434
define('MOODLE_INTERNAL', true);
435435
}
436436

437-
// core_component can be used in any scripts, it does not need anything else.
437+
// The core_component class can be used in any scripts, it does not need anything else.
438438
require_once($CFG->libdir .'/classes/component.php');
439439

440440
// Early profiling start, based exclusively on config.php $CFG settings

0 commit comments

Comments
 (0)
Please sign in to comment.