From 1da8d303ef757d2a7bbe2ac5d7dbe6705515db1f Mon Sep 17 00:00:00 2001 From: Ankit Agarwal Date: Tue, 19 Sep 2017 11:27:24 +0530 Subject: [PATCH] MDL-59780 mathjax: Make sure mathjax url doesn't become empty --- filter/mathjaxloader/db/upgrade.php | 13 ++++++++++++- filter/mathjaxloader/version.php | 2 +- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/filter/mathjaxloader/db/upgrade.php b/filter/mathjaxloader/db/upgrade.php index e47f34c467d..29f958cec7d 100644 --- a/filter/mathjaxloader/db/upgrade.php +++ b/filter/mathjaxloader/db/upgrade.php @@ -138,7 +138,8 @@ MathJax.Hub.Config({ // 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'); @@ -196,5 +197,15 @@ MathJax.Hub.Config({ upgrade_plugin_savepoint(true, 2016120502, 'filter', 'mathjaxloader'); } + if ($oldversion < 2016120503) { + + $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, 2016120503, 'filter', 'mathjaxloader'); + } + return true; } diff --git a/filter/mathjaxloader/version.php b/filter/mathjaxloader/version.php index a025359493e..3349371aae1 100644 --- a/filter/mathjaxloader/version.php +++ b/filter/mathjaxloader/version.php @@ -24,6 +24,6 @@ defined('MOODLE_INTERNAL') || die(); -$plugin->version = 2016120502; +$plugin->version = 2016120503; $plugin->requires = 2016112900; // Requires this Moodle version. $plugin->component= 'filter_mathjaxloader';