Skip to content

Commit

Permalink
MDL-53572 mathjax: always load mathjax using https
Browse files Browse the repository at this point in the history
It's considered an anti-pattern now to use protocol relative urls and
reduces a setting.

(Also fixed an incorrectly placed 3.1.0 upgrade marker)
  • Loading branch information
danpoltawski committed Aug 2, 2016
1 parent d1a3ea6 commit 8ce58c9
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 20 deletions.
23 changes: 20 additions & 3 deletions filter/mathjaxloader/db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,6 @@ function xmldb_filter_mathjaxloader_upgrade($oldversion) {
// Moodle v3.0.0 release upgrade line.
// Put any upgrade step following this.

// Moodle v3.1.0 release upgrade line.
// Put any upgrade step following this.

if ($oldversion < 2016032200) {

$httpurl = get_config('filter_mathjaxloader', 'httpurl');
Expand All @@ -131,5 +128,25 @@ function xmldb_filter_mathjaxloader_upgrade($oldversion) {
upgrade_plugin_savepoint(true, 2016032200, 'filter', 'mathjaxloader');
}

// Moodle v3.1.0 release upgrade line.
// Put any upgrade step following this.

if ($oldversion < 2016080200) {
// We are consolodating the two settings for http and https url into only the https
// 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 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');
}

// The seperate http setting has been removed. We always use the secure resource.
unset_config('httpurl', 'filter_mathjaxloader');

upgrade_plugin_savepoint(true, 2016080200, 'filter', 'mathjaxloader');
}

return true;
}
6 changes: 1 addition & 5 deletions filter/mathjaxloader/filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,7 @@ public function setup($page, $context) {
static $jsinitialised = false;

if (empty($jsinitialised)) {
if (is_https()) {
$url = get_config('filter_mathjaxloader', 'httpsurl');
} else {
$url = get_config('filter_mathjaxloader', 'httpurl');
}
$url = get_config('filter_mathjaxloader', 'httpsurl');
$lang = $this->map_language_code(current_language());
$url = new moodle_url($url, array('delayStartupUntil' => 'configured'));

Expand Down
6 changes: 2 additions & 4 deletions filter/mathjaxloader/lang/en/filter_mathjaxloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,8 @@
$string['additionaldelimiters_help'] = 'MathJax filter parses text for equations contained within delimiter characters.
The list of recognised delimiter characters can be added to here (e.g. AsciiMath uses `). Delimiters can contain multiple characters and multiple delimiters can be separated with commas.';
$string['httpurl'] = 'HTTP MathJax URL';
$string['httpurl_help'] = 'Full URL to MathJax library. Used when the page is loaded via http.';
$string['httpsurl'] = 'HTTPS MathJax URL';
$string['httpsurl_help'] = 'Full URL to MathJax library. Used when the page is loaded via https (secure). ';
$string['httpsurl'] = 'MathJax URL';
$string['httpsurl_help'] = 'Full URL to MathJax library.';
$string['texfiltercompatibility'] = 'TeX filter compatibility';
$string['texfiltercompatibility_help'] = 'The MathJax filter can be used as a replacement for the TeX notation filter.
Expand Down
7 changes: 0 additions & 7 deletions filter/mathjaxloader/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,6 @@
new lang_string('localinstall_help', 'filter_mathjaxloader'));
$settings->add($item);

$item = new admin_setting_configtext('filter_mathjaxloader/httpurl',
new lang_string('httpurl', 'filter_mathjaxloader'),
new lang_string('httpurl_help', 'filter_mathjaxloader'),
'http://cdn.mathjax.org/mathjax/2.6-latest/MathJax.js',
PARAM_RAW);
$settings->add($item);

$item = new admin_setting_configtext('filter_mathjaxloader/httpsurl',
new lang_string('httpsurl', 'filter_mathjaxloader'),
new lang_string('httpsurl_help', 'filter_mathjaxloader'),
Expand Down
2 changes: 1 addition & 1 deletion filter/mathjaxloader/version.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@

defined('MOODLE_INTERNAL') || die();

$plugin->version = 2016052300;
$plugin->version = 2016080200;
$plugin->requires = 2016051900; // Requires this Moodle version.
$plugin->component= 'filter_mathjaxloader';

0 comments on commit 8ce58c9

Please sign in to comment.