MDL-64429 tool_usertours: upgrade step to fix existing tours sortorder.

This commit is contained in:
Paul Holden
2020-03-26 16:48:59 +00:00
parent 8dabade61f
commit 091758d512
3 changed files with 11 additions and 1 deletions
+3
View File
@@ -897,6 +897,9 @@ class manager {
}
$existingtourrecords->close();
// Ensure we correct the sortorder in any existing tours, prior to adding latest shipped tours.
helper::reset_tour_sortorder();
foreach (array_reverse($shippedtours) as $filename => $version) {
$filepath = $CFG->dirroot . "/{$CFG->admin}/tool/usertours/tours/" . $filename;
$tourjson = file_get_contents($filepath);
+7
View File
@@ -61,5 +61,12 @@ function xmldb_tool_usertours_upgrade($oldversion) {
// Automatically generated Moodle v3.8.0 release upgrade line.
// Put any upgrade step following this.
if ($oldversion < 2020031900) {
// Updating shipped tours will fix broken sortorder records in existing tours.
manager::update_shipped_tours();
upgrade_plugin_savepoint(true, 2020031900, 'tool', 'usertours');
}
return true;
}
+1 -1
View File
@@ -24,6 +24,6 @@
defined('MOODLE_INTERNAL') || die();
$plugin->version = 2019120400; // The current module version (Date: YYYYMMDDXX).
$plugin->version = 2020031900; // The current module version (Date: YYYYMMDDXX).
$plugin->requires = 2019111200; // Requires this Moodle version.
$plugin->component = 'tool_usertours'; // Full name of the plugin (used for diagnostics).