From 3c9ca9007bc13fd5d92c2b5c6e86a67633f85b9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Mudr=C3=A1k?= Date: Fri, 19 Aug 2022 11:25:58 +0200 Subject: [PATCH] MDL-75534 Fix usermodified in very old forum discussions Very early Moodle versions used to leave the field empty. Recent Moodle versions expect that the value always links to an existing user account. --- mod/forum/db/upgrade.php | 7 +++++++ mod/forum/version.php | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/mod/forum/db/upgrade.php b/mod/forum/db/upgrade.php index cf0d1ab03bc45..c61de8546b14a 100644 --- a/mod/forum/db/upgrade.php +++ b/mod/forum/db/upgrade.php @@ -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; } diff --git a/mod/forum/version.php b/mod/forum/version.php index f8c383b188d89..284c45428d03a 100644 --- a/mod/forum/version.php +++ b/mod/forum/version.php @@ -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)