diff --git a/lib/classes/plugin_manager.php b/lib/classes/plugin_manager.php index 99d17f4dd6e..15d170ec2f0 100644 --- a/lib/classes/plugin_manager.php +++ b/lib/classes/plugin_manager.php @@ -288,15 +288,24 @@ class core_plugin_manager { foreach ($plugintypes as $type => $typedir) { $plugs = core_component::get_plugin_list($type); foreach ($plugs as $plug => $fullplug) { + $module = new stdClass(); $plugin = new stdClass(); $plugin->version = null; - $module = $plugin; include($fullplug.'/version.php'); + + // Check if the legacy $module syntax is still used. + if (!is_object($module) or (!empty((array)$module))) { + debugging('Unsupported $module syntax detected in version.php of the '.$type.'_'.$plug.' plugin.'); + $skipcache = true; + } + $this->presentplugins[$type][$plug] = $plugin; } } - $cache->set('present', $this->presentplugins); + if (empty($skipcache)) { + $cache->set('present', $this->presentplugins); + } } /** diff --git a/lib/upgradelib.php b/lib/upgradelib.php index d2d07727456..dc0865f7d41 100644 --- a/lib/upgradelib.php +++ b/lib/upgradelib.php @@ -600,12 +600,18 @@ function upgrade_plugins_modules($startcallback, $endcallback, $verbose) { throw new plugin_defective_exception($component, 'Missing version.php'); } - // TODO: Support for $module will end with Moodle 2.10 by MDL-43896. Was deprecated for Moodle 2.7 by MDL-43040. + $module = new stdClass(); $plugin = new stdClass(); $plugin->version = null; - $module = $plugin; require($fullmod .'/version.php'); // Defines $plugin with version etc. - $plugin = clone($module); + + // Check if the legacy $module syntax is still used. + if (!is_object($module) or (!empty((array)$module))) { + throw new plugin_defective_exception($component, 'Unsupported $module syntax detected in version.php'); + } + + // Prepare the record for the {modules} table. + $module = clone($plugin); unset($module->version); unset($module->component); unset($module->dependencies); diff --git a/mod/upgrade.txt b/mod/upgrade.txt index 2eaa8aeb1d2..9a93e9139f2 100644 --- a/mod/upgrade.txt +++ b/mod/upgrade.txt @@ -3,7 +3,11 @@ information provided here is intended especially for developers. === 3.0 === -* Function scorm_view_display was renamed to scorm_print_launch to avoid confussion with new function scorm_view. +* Dropped support for the $module in mod/xxx/version.php files (deprecated + since 2.7). All activity modules must use the $plugin syntax now. See + https://docs.moodle.org/dev/version.php for details (MDL-43896). +* Function scorm_view_display was renamed to scorm_print_launch to avoid + confussion with new function scorm_view. === 2.9 ===