From 5800832af86362a5454a58e61df9067504328a98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Mudr=C3=A1k?= Date: Wed, 5 Dec 2012 23:47:54 +0100 Subject: [PATCH] MDL-36943 Do not notify about already installed updates Before this patch, the available_update_checker::cron_notifications() method accessed the availableupdates property. But for plugins, that property basically contains the most recent version available. So we were missing the check against the actual version installed. The fix was simple - obtain available updates via the available_updates() method that performs the check. --- lib/pluginlib.php | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/lib/pluginlib.php b/lib/pluginlib.php index 5d78cf7c9e7e9..881122c70d581 100644 --- a/lib/pluginlib.php +++ b/lib/pluginlib.php @@ -1195,15 +1195,18 @@ protected function cron_notifications(array $changes) { // $componentupdate is a real update with higher version $notifications[] = $componentupdate; } else { - // use the plugin_manager to check if the reported $componentchange - // is a real update with higher version. such a real update must be - // present in the 'availableupdates' property of one of the component's - // available_update_info object + // Use the plugin_manager to check if the detected $componentchange + // is a real update with higher version. That is, the $componentchange + // is present in the array of {@link available_update_info} objects + // returned by the plugin's available_updates() method. list($plugintype, $pluginname) = normalize_component($component); - if (!empty($plugins[$plugintype][$pluginname]->availableupdates)) { - foreach ($plugins[$plugintype][$pluginname]->availableupdates as $availableupdate) { - if ($availableupdate->version == $componentchange['version']) { - $notifications[] = $componentupdate; + if (!empty($plugins[$plugintype][$pluginname])) { + $availableupdates = $plugins[$plugintype][$pluginname]->available_updates(); + if (!empty($availableupdates)) { + foreach ($availableupdates as $availableupdate) { + if ($availableupdate->version == $componentchange['version']) { + $notifications[] = $componentupdate; + } } } }