Skip to content

Commit

Permalink
MDL-64429 tool_usertours: upgrade step to fix existing tours sortorder.
Browse files Browse the repository at this point in the history
  • Loading branch information
paulholden committed Mar 26, 2020
1 parent 241edb4 commit 02e24d7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
3 changes: 3 additions & 0 deletions admin/tool/usertours/classes/manager.php
Expand Up @@ -897,6 +897,9 @@ public static function update_shipped_tours() {
}
$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);
Expand Down
7 changes: 7 additions & 0 deletions admin/tool/usertours/db/upgrade.php
Expand Up @@ -67,5 +67,12 @@ function xmldb_tool_usertours_upgrade($oldversion) {
// Automatically generated Moodle v3.8.0 release upgrade line.
// Put any upgrade step following this.

if ($oldversion < 2019111801) {
// Updating shipped tours will fix broken sortorder records in existing tours.
manager::update_shipped_tours();

upgrade_plugin_savepoint(true, 2019111801, 'tool', 'usertours');
}

return true;
}
2 changes: 1 addition & 1 deletion admin/tool/usertours/version.php
Expand Up @@ -24,6 +24,6 @@

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

$plugin->version = 2019111800; // The current module version (Date: YYYYMMDDXX).
$plugin->version = 2019111801; // 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).

0 comments on commit 02e24d7

Please sign in to comment.