From 85d751631328277b40ce88f4ed9cc67bb4494e96 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?David=20Mudr=C3=A1k?= <david@moodle.com>
Date: Wed, 7 Nov 2012 09:50:59 +0100
Subject: [PATCH] MDL-35238 Fetch available updates using the 1.1 version of
 the API

If the stored response has still 1.0 version (which is expected during
the upgrade to 2.4), a debugging message is displayed. Added a string to
explain what's going on and how to recover from the state.
---
 lang/en/plugin.php | 1 +
 lib/pluginlib.php  | 4 ++--
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/lang/en/plugin.php b/lang/en/plugin.php
index 8b692959861..6812824c87f 100644
--- a/lang/en/plugin.php
+++ b/lang/en/plugin.php
@@ -30,6 +30,7 @@ $string['availability'] = 'Availability';
 $string['checkforupdates'] = 'Check for available updates';
 $string['checkforupdateslast'] = 'Last check done on {$a}';
 $string['displayname'] = 'Plugin name';
+$string['err_response_format_version'] = 'Unexpected version of the response format. Please try to re-check for available updates.';
 $string['filterall'] = 'Show all';
 $string['filtercontribonly'] = 'Show contributions only';
 $string['filtercontribonlyactive'] = 'Showing contributions only';
diff --git a/lib/pluginlib.php b/lib/pluginlib.php
index e0c51365b03..e3fd1f3448b 100644
--- a/lib/pluginlib.php
+++ b/lib/pluginlib.php
@@ -852,7 +852,7 @@ class available_update_checker {
             throw new available_update_checker_exception('err_response_status', $response['status']);
         }
 
-        if (empty($response['apiver']) or $response['apiver'] !== '1.0') {
+        if (empty($response['apiver']) or $response['apiver'] !== '1.1') {
             throw new available_update_checker_exception('err_response_format_version', $response['apiver']);
         }
 
@@ -990,7 +990,7 @@ class available_update_checker {
         if (!empty($CFG->alternativeupdateproviderurl)) {
             return $CFG->alternativeupdateproviderurl;
         } else {
-            return 'http://download.moodle.org/api/1.0/updates.php';
+            return 'http://download.moodle.org/api/1.1/updates.php';
         }
     }