Skip to content

Commit

Permalink
MDL-75534 Fix usermodified in very old forum discussions
Browse files Browse the repository at this point in the history
Very early Moodle versions used to leave the field empty. Recent Moodle
versions expect that the value always links to an existing user account.
  • Loading branch information
mudrd8mz committed Oct 19, 2022
1 parent f8d28e4 commit 3c9ca90
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions mod/forum/db/upgrade.php
Expand Up @@ -173,5 +173,12 @@ function xmldb_forum_upgrade($oldversion) {
upgrade_mod_savepoint(true, 2022072900, 'forum');
}

if ($oldversion < 2022081900) {
// Some very old discussions from early Moodle versions may have the usermodified set to zero.
$DB->execute("UPDATE {forum_discussions} SET usermodified = userid WHERE usermodified = 0");

upgrade_mod_savepoint(true, 2022081900, 'forum');
}

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

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

$plugin->version = 2022072900; // The current module version (Date: YYYYMMDDXX).
$plugin->version = 2022081900; // The current module version (Date: YYYYMMDDXX).
$plugin->requires = 2022041200; // Requires this Moodle version.
$plugin->component = 'mod_forum'; // Full name of the plugin (used for diagnostics)

0 comments on commit 3c9ca90

Please sign in to comment.