MDL-53978 core: Do not run callbacks if upgrade is running
authorAndrew Nicols <andrew@nicols.co.uk>
Thu, 2 Mar 2017 01:15:10 +0000 (09:15 +0800)
committerAndrew Nicols <andrew@nicols.co.uk>
Thu, 2 Mar 2017 02:24:05 +0000 (10:24 +0800)
lib/moodlelib.php

index 304eeec..b939f2a 100644 (file)
@@ -7474,6 +7474,11 @@ function get_plugin_list_with_function($plugintype, $function, $file = 'lib.php'
 function get_plugins_with_function($function, $file = 'lib.php', $include = true) {
     global $CFG;
 
+    if (during_initial_install() || isset($CFG->upgraderunning)) {
+        // API functions _must not_ be called during an installation or upgrade.
+        return [];
+    }
+
     $cache = \cache::make('core', 'plugin_functions');
 
     // Including both although I doubt that we will find two functions definitions with the same name.