Skip to content

Commit

Permalink
Merge branch 'MDL-67696-MOODLE_38_STABLE_count_warning' of https://gi…
Browse files Browse the repository at this point in the history
…thub.com/JayChurchward/moodle into MOODLE_38_STABLE
  • Loading branch information
sarjona committed Mar 4, 2020
2 parents 2f7e2ff + 7476acd commit a552c30
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions mod/forum/classes/task/refresh_forum_post_counts.php
Expand Up @@ -54,9 +54,12 @@ public function execute() {
protected function update_null_forum_post_counts(): bool {
global $CFG, $DB;

// Default to chunks of 5000 records per run, unless overridden in config.php
// Default to chunks of 5000 records per run, unless overridden in config.php.
$chunksize = $CFG->forumpostcountchunksize ?? 5000;

// Initialize counter.
$recordscount = 0;

$select = 'wordcount IS NULL OR charcount IS NULL';
$recordset = $DB->get_recordset_select('forum_posts', $select, null, 'discussion', 'id, message', 0, $chunksize);

Expand All @@ -68,9 +71,9 @@ protected function update_null_forum_post_counts(): bool {
foreach ($recordset as $record) {
\mod_forum\local\entities\post::add_message_counts($record);
$DB->update_record('forum_posts', $record);
$recordscount++;
}

$recordscount = count($recordset);
$recordset->close();

return ($recordscount == $chunksize);
Expand Down

0 comments on commit a552c30

Please sign in to comment.