-
Bug
-
Resolution: Fixed
-
Minor
-
4.0.2, 4.0.6, 4.1.1
-
MOODLE_400_STABLE, MOODLE_401_STABLE
-
MOODLE_400_STABLE, MOODLE_401_STABLE
-
MDL-75534-master-forum-usermodified-zero -
-
As noticed today by dougiamas, some very first posts from the very first Moodle forum https://moodle.org/mod/forum/view.php?f=1 were not displayed. I was able to reproduce the problem and trace it down to https://github.com/moodle/moodle/blob/17ee0726933c7c6410aca0e1edc445f795774c07/mod/forum/classes/local/vaults/discussion_list.php#L156
$tables .= ' JOIN {user} la ON la.id = ' . $alias . '.usermodified';
|
The SQL that fetches records from the database, uses the INNER JOIN against the user table on the value forum_discussions.usermodified. For new discussions, Moodle sets usermodified to the author of the first post so it works well.
But very early Moodle versions used to leave that field set to zero (that was changed somewhere around versions 1.1 or 1.2). So in our case, discussions that were never replied to, still had the usermodified set to 0 for these 20 years old discussions. And so they were not displayed.
The fix is simple:
UPDATE forum_discussions SET usermodified = userid WHERE usermodified = 0;
|
and I think it is something we should do in a forum upgrade step.