MDL-59780 mathjax: Make sure mathjax url doesn't become empty
authorAnkit Agarwal <ankit@moodle.com>
Tue, 19 Sep 2017 05:57:24 +0000 (11:27 +0530)
committerAnkit Agarwal <ankit@moodle.com>
Wed, 27 Sep 2017 03:44:20 +0000 (09:14 +0530)
filter/mathjaxloader/db/upgrade.php
filter/mathjaxloader/version.php

index a2a9070..d2cdf69 100644 (file)
@@ -58,7 +58,8 @@ function xmldb_filter_mathjaxloader_upgrade($oldversion) {
         // setting. Since it is preferably to always load the secure resource.
 
         $httpurl = get_config('filter_mathjaxloader', 'httpurl');
-        if ($httpurl !== 'http://cdn.mathjax.org/mathjax/2.6-latest/MathJax.js') {
+        if ($httpurl !== 'http://cdn.mathjax.org/mathjax/2.6-latest/MathJax.js' &&
+            $httpurl !== 'http://cdn.mathjax.org/mathjax/2.6.1/MathJax.js') {
             // If the http setting has been changed, we make the admin choose the https setting because
             // it indicates some sort of custom setup. This will be supported by the release notes.
             unset_config('httpsurl', 'filter_mathjaxloader');
@@ -120,5 +121,15 @@ function xmldb_filter_mathjaxloader_upgrade($oldversion) {
     // Automatically generated Moodle v3.3.0 release upgrade line.
     // Put any upgrade step following this.
 
+    if ($oldversion < 2017091900) {
+
+        $httpsurl = get_config('filter_mathjaxloader', 'httpsurl');
+        if (empty($httpsurl)) {
+            // URL is empty, most likely because of bad upgrade path. See MDL-59780.
+            set_config('httpsurl', 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js', 'filter_mathjaxloader');
+        }
+        upgrade_plugin_savepoint(true, 2017091900, 'filter', 'mathjaxloader');
+    }
+
     return true;
 }
index d2042a7..724fdee 100644 (file)
@@ -24,6 +24,6 @@
 
 defined('MOODLE_INTERNAL') || die();
 
-$plugin->version  = 2017051500;
+$plugin->version  = 2017091900;
 $plugin->requires = 2017050500;  // Requires this Moodle version.
 $plugin->component= 'filter_mathjaxloader';