MDL-67696 mod_forum: Changed invalid count() to loop counter.

This commit is contained in:
JayChurchward 2020-01-30 15:01:24 -05:00
parent cb38ab1e39
commit 72eaa3c916

View File

@ -54,9 +54,12 @@ class refresh_forum_post_counts extends \core\task\adhoc_task {
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);
@ -68,9 +71,9 @@ class refresh_forum_post_counts extends \core\task\adhoc_task {
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);