From 70f7b59c3c65dcf67678f1426b7efe4465b6ff50 Mon Sep 17 00:00:00 2001 From: Paul Holden Date: Thu, 11 Jan 2024 20:45:40 +0000 Subject: [PATCH] MDL-80516 core: more robust plugin update component checking. Occurs when a plugin in incorrectly removed (via file system only, rather than following proper uninstall process), and also contains it's own sub-plugins. In the above scenario, the update would request and receive back a response for a plugin whose name was comprised of an empty string, subsequently causing errors when processing said response. --- lib/classes/plugin_manager.php | 2 +- lib/classes/update/checker.php | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/classes/plugin_manager.php b/lib/classes/plugin_manager.php index 6acdf85c850..ed4bce2d9aa 100644 --- a/lib/classes/plugin_manager.php +++ b/lib/classes/plugin_manager.php @@ -1550,7 +1550,7 @@ class core_plugin_manager { $provider = \core\update\checker::instance(); - if (!$provider->enabled() or during_initial_install()) { + if (!$provider->enabled() || $component === '' || during_initial_install()) { return null; } diff --git a/lib/classes/update/checker.php b/lib/classes/update/checker.php index ba19c15c4d6..a2e132ef527 100644 --- a/lib/classes/update/checker.php +++ b/lib/classes/update/checker.php @@ -440,8 +440,11 @@ class checker { $pluginman = \core_plugin_manager::instance(); foreach ($pluginman->get_plugins() as $type => $plugins) { + // Iterate over installed plugins and determine which are non-standard and eligible for update checks. Note that we + // disregard empty component names here, to ensure we only request valid data from the update site (in the case of an + // improperly removed plugin containing sub-plugins, we would get an empty value here for each sub-plugin). foreach ($plugins as $plugin) { - if (!$plugin->is_standard()) { + if ($plugin->component !== '' && !$plugin->is_standard()) { $this->currentplugins[$plugin->component] = $plugin->versiondisk; } }