mirror of
https://github.com/moodle/moodle.git
synced 2025-04-05 00:12:42 +02:00
MDL-67696 mod_forum: Changed invalid count() to loop counter.
This commit is contained in:
parent
cb38ab1e39
commit
72eaa3c916
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user