Skip to content

Commit

Permalink
MDL-65809 upgrade: remove filter_mathjaxloader_upgrade_xxx
Browse files Browse the repository at this point in the history
These functions were used only by deleted upgrade steps
so it's safe to proceed with straight deletion, considering
them internal. Deletion has been documented in corresponding
upgrade.txt files:

    - filter_mathjaxloader_upgrade_cdn_cloudflare()
    - filter_mathjaxloader_upgrade_mathjaxconfig_equal()
  • Loading branch information
sarjona committed Dec 20, 2019
1 parent 3f224a1 commit 08bc1f1
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 342 deletions.
123 changes: 0 additions & 123 deletions filter/mathjaxloader/db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,129 +31,6 @@
function xmldb_filter_mathjaxloader_upgrade($oldversion) {
global $CFG;

require_once($CFG->dirroot . '/filter/mathjaxloader/db/upgradelib.php');

if ($oldversion < 2017040300) {

$httpsurl = get_config('filter_mathjaxloader', 'httpsurl');
$newcdnurl = filter_mathjaxloader_upgrade_cdn_cloudflare($httpsurl, false);

set_config('httpsurl', $newcdnurl, 'filter_mathjaxloader');

$mathjaxconfig = get_config('filter_mathjaxloader', 'mathjaxconfig');
if (strpos($mathjaxconfig, 'MathJax.Ajax.config.path') === false) {
$newconfig = 'MathJax.Ajax.config.path["Contrib"] = "{wwwroot}/filter/mathjaxloader/contrib";' . "\n";
$newconfig .= $mathjaxconfig;

set_config('mathjaxconfig', $newconfig, 'filter_mathjaxloader');
}

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

if ($oldversion < 2017042602) {

$httpsurl = get_config('filter_mathjaxloader', 'httpsurl');
if ($httpsurl === "https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js") {
set_config('httpsurl', 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js', 'filter_mathjaxloader');
}

$mathjaxconfig = get_config('filter_mathjaxloader', 'mathjaxconfig');

if (strpos($mathjaxconfig, 'MathJax.Ajax.config.path') !== false) {
// Now we need to remove this config again because mathjax 2.7.1 supports the extensions on the CDN.
$configtoremove = 'MathJax.Ajax.config.path["Contrib"] = "{wwwroot}/filter/mathjaxloader/contrib";';

$mathjaxconfig = str_replace($configtoremove, '', $mathjaxconfig);

set_config('mathjaxconfig', $mathjaxconfig, 'filter_mathjaxloader');
}

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

// 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');
}

if ($oldversion < 2017100900) {
// Update the MathJax CDN URL to the new default if the site has been using default value.
$httpsurl = get_config('filter_mathjaxloader', 'httpsurl');
if ($httpsurl === 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js') {
set_config('httpsurl', 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.2/MathJax.js', 'filter_mathjaxloader');
}
upgrade_plugin_savepoint(true, 2017100900, 'filter', 'mathjaxloader');
}

if ($oldversion < 2017101200) {
// Update default MathJax configuration so that it does not use the Accessible.js config (causes JS errors due to upstream bug).
$previousdefault = '
MathJax.Hub.Config({
config: ["Accessible.js", "Safe.js"],
errorSettings: { message: ["!"] },
skipStartupTypeset: true,
messageStyle: "none"
});
';

$newdefault = '
MathJax.Hub.Config({
config: ["default.js", "MMLorHTML.js", "Safe.js"],
errorSettings: { message: ["!"] },
skipStartupTypeset: true,
messageStyle: "none"
});
';

$mathjaxconfig = get_config('filter_mathjaxloader', 'mathjaxconfig');

if (empty($mathjaxconfig) || filter_mathjaxloader_upgrade_mathjaxconfig_equal($mathjaxconfig, $previousdefault)) {
set_config('mathjaxconfig', $newdefault, 'filter_mathjaxloader');
}

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

if ($oldversion < 2017102000) {
// Re-add Accessible.js (we should not have removed it).
$previousdefault = '
MathJax.Hub.Config({
config: ["default.js", "MMLorHTML.js", "Safe.js"],
errorSettings: { message: ["!"] },
skipStartupTypeset: true,
messageStyle: "none"
});
';
$newdefault = '
MathJax.Hub.Config({
config: ["Accessible.js", "Safe.js"],
errorSettings: { message: ["!"] },
skipStartupTypeset: true,
messageStyle: "none"
});
';

$mathjaxconfig = get_config('filter_mathjaxloader', 'mathjaxconfig');

if (empty($mathjaxconfig) || filter_mathjaxloader_upgrade_mathjaxconfig_equal($mathjaxconfig, $previousdefault)) {
set_config('mathjaxconfig', $newdefault, 'filter_mathjaxloader');
}

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

// Automatically generated Moodle v3.4.0 release upgrade line.
// Put any upgrade step following this.

// Automatically generated Moodle v3.5.0 release upgrade line.
// Put any upgrade step following this.

Expand Down
95 changes: 0 additions & 95 deletions filter/mathjaxloader/db/upgradelib.php

This file was deleted.

124 changes: 0 additions & 124 deletions filter/mathjaxloader/tests/upgradelib_test.php

This file was deleted.

6 changes: 6 additions & 0 deletions filter/upgrade.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
This file describes API changes in core filter API and plugins,
information provided here is intended especially for developers.

=== 3.9 ===

* The following functions, previously used (exclusively) by upgrade steps are not available anymore because of the upgrade cleanup performed for this version. See MDL-65809 for more info:
- filter_mathjaxloader_upgrade_cdn_cloudflare()
- filter_mathjaxloader_upgrade_mathjaxconfig_equal()

=== 3.6 ===

* Although there is no API change that require you to update your filter,
Expand Down

0 comments on commit 08bc1f1

Please sign in to comment.