From 927cb511666780f10130677cbb7e493d0c4e3c57 Mon Sep 17 00:00:00 2001 From: David Mudrak Date: Thu, 24 May 2012 14:30:04 +0200 Subject: [PATCH] MDL-32329 plugin manager returns plugins with unsatisfied dependencies --- lib/pluginlib.php | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/lib/pluginlib.php b/lib/pluginlib.php index df5239c4995..08875353b71 100644 --- a/lib/pluginlib.php +++ b/lib/pluginlib.php @@ -280,25 +280,35 @@ class plugin_manager { } /** - * Checks all dependencies for all installed plugins. Used by install and upgrade. + * Checks all dependencies for all installed plugins + * + * This is used by install and upgrade. The array passed by reference as the second + * argument is populated with the list of plugins that have failed dependencies (note that + * a single plugin can appear multiple times in the $failedplugins). + * * @param int $moodleversion the version from version.php. + * @param array $failedplugins to return the list of plugins with non-satisfied dependencies * @return bool true if all the dependencies are satisfied for all plugins. */ - public function all_plugins_ok($moodleversion) { + public function all_plugins_ok($moodleversion, &$failedplugins = array()) { + + $return = true; foreach ($this->get_plugins() as $type => $plugins) { foreach ($plugins as $plugin) { if (!empty($plugin->versionrequires) && $plugin->versionrequires > $moodleversion) { - return false; + $return = false; + $failedplugins[] = $plugin->component; } if (!$this->are_dependencies_satisfied($plugin->get_other_required_plugins())) { - return false; + $return = false; + $failedplugins[] = $plugin->component; } } } - return true; + return $return; } /**