Skip to content

Commit d1c565a

Browse files
committed
Support the new 'public' directory in MDL-83424.
1 parent 31cfd83 commit d1c565a

File tree

2 files changed

+21
-16
lines changed

2 files changed

+21
-16
lines changed

list_valid_components/list_valid_components.php

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -127,19 +127,13 @@
127127
exit(0);
128128
}
129129

130-
// Up to Moodle 2.5, we use the old global API, that requires the site to be installed
131-
// (the shell script calling this handles those reqs automatically)
132-
// TODO: Once 2.5 is out we can change this by the new core_component::get_xxx() calls.
133-
// until then will be using the deprecated ones.
134-
require(dirname(dirname(dirname(dirname(__FILE__)))).'/config.php');
135-
136130
// Get all the plugin and subplugin types
137-
$types = get_plugin_types(true);
131+
$types = \core_component::get_plugin_types();
138132
// Sort types in reverse order, so we get subplugins earlier than plugins
139133
$types = array_reverse($types);
140134
// For each type, get their available implementations
141135
foreach ($types as $type => $fullpath) {
142-
$plugins = get_plugin_list($type);
136+
$plugins = $types = \core_component::get_plugin_list($type);
143137
// For each plugin, let's calculate the proper component name and generate
144138
// the corresponding build.xml file
145139
foreach ($plugins as $plugin => $pluginpath) {
@@ -157,7 +151,7 @@
157151

158152
// Get all the subsystems and
159153
// generate the corresponding build.xml file
160-
$subsystems = get_core_subsystems(true);
154+
$subsystems = $types = \core_component::get_core_subsystems();
161155
$subsystems['core'] = $options['basedir']; // To get the main one too
162156
foreach ($subsystems as $subsystem => $subsystempath) {
163157
if ($subsystem == 'backup') { // Because I want, yes :-P

phplib/clilib.php

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -222,20 +222,31 @@ function s($var) {
222222
* @return bool false if core_component wasn't able to be loaded.
223223
*/
224224
function load_core_component_from_moodle($moodledirroot) {
225-
if (!file_exists($moodledirroot . '/lib/classes/component.php')) {
225+
if (file_exists($moodledirroot . '/public/lib/classes/component.php')) {
226+
// Suppor the Moodle 5.1 'public' directory structure.
227+
$newcfg = (object) [
228+
'dirroot' => "{$moodledirroot}/public",
229+
'root' => $moodledirroot,
230+
'libdir' => "{$moodledirroot}/public/lib",
231+
'filepermissions' => '0666',
232+
];
233+
} else if (!file_exists($moodledirroot . '/lib/classes/component.php')) {
234+
$newcfg = (object) [
235+
'dirroot' => $moodledirroot,
236+
'libdir' => $moodledirroot . '/lib',
237+
'filepermissions' => '0666',
238+
];
239+
} else {
226240
return false;
227241
}
228242

229243
define('IGNORE_COMPONENT_CACHE', 1);
230244
define('MOODLE_INTERNAL', 1);
231245
unset($CFG);
232246
global $CFG;
233-
$CFG = new stdClass();
234-
$CFG->dirroot = $moodledirroot;
235-
$CFG->libdir = $CFG->dirroot . '/lib';
236-
$CFG->admin = 'admin';
237-
$CFG->filepermissions = '0666';
238-
require_once($CFG->dirroot . '/lib/classes/component.php');
247+
$CFG = $newcfg;
248+
249+
require_once($CFG->libdir . '/classes/component.php');
239250

240251
return true;
241252
}

0 commit comments

Comments
 (0)