From 1530136c2086c3d90cce63f8ca43e3ddeb871fb9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20Mudr=C3=A1k?= Date: Mon, 10 Sep 2012 17:29:42 +0200 Subject: [PATCH] MDL-35344 Ignore available updates info with invalid format Previously when the server response validation had failed, the property available_update_checker::recentresponse was left as NULL. This caused problems in available_update_checker::compare_responses() that expects proper arrays passed. This patch makes invalid data being ignored by setting the property to an empty array as if no data have been fetched yet. A debugging message is thrown so the admins will be able to diagnose eventual problems in the future. --- lib/pluginlib.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/pluginlib.php b/lib/pluginlib.php index 65e1c35623a..76e50ebba85 100644 --- a/lib/pluginlib.php +++ b/lib/pluginlib.php @@ -843,6 +843,11 @@ class available_update_checker { /** * Loads the most recent raw response record we have fetched * + * After this method is called, $this->recentresponse is set to an array. If the + * array is empty, then either no data have been fetched yet or the fetched data + * do not have expected format (and thence they are ignored and a debugging + * message is displayed). + * * This implementation uses the config_plugins table as the permanent storage. * * @param bool $forcereload reload even if it was already loaded @@ -862,7 +867,8 @@ class available_update_checker { $this->recentfetch = $config->recentfetch; $this->recentresponse = $this->decode_response($config->recentresponse); } catch (available_update_checker_exception $e) { - // do not set recentresponse if the validation fails + debugging('Invalid info about available updates detected and will be ignored: '.$e->getMessage(), DEBUG_ALL); + $this->recentresponse = array(); } } else { -- 2.43.0