Browse files

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.
  • Loading branch information...
1 parent 935c3d5 commit c62580b9d036374aab60c6251647a4a22c1649fd @mudrd8mz mudrd8mz committed Sep 10, 2012
Showing with 7 additions and 1 deletion.
  1. +7 −1 lib/pluginlib.php
View
8 lib/pluginlib.php
@@ -861,6 +861,11 @@ protected function store_response($response) {
/**
* 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
@@ -880,7 +885,8 @@ protected function restore_response($forcereload = false) {
$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 {

0 comments on commit c62580b

Please sign in to comment.