-
Bug
-
Resolution: Fixed
-
Minor
-
3.8.1
-
MOODLE_38_STABLE
-
MOODLE_38_STABLE
-
MDL-67696-master -
-
International 3.9 - Sprint 6
PHP Warning: count(): Parameter must be an array or an object that implements Countable in mod/forum/classes/task/refresh_forum_post_counts.php on line 73
code block reads:
protected function update_null_forum_post_counts(): bool { |
global $CFG, $DB;
|
|
// Default to chunks of 5000 records per run, unless overridden in config.php |
$chunksize = $CFG->forumpostcountchunksize ?? 5000; |
|
$select = 'wordcount IS NULL OR charcount IS NULL'; |
$recordset = $DB->get_recordset_select('forum_posts', $select, null, 'discussion', 'id, message', 0, $chunksize); |
|
if (!$recordset->valid()) { |
$recordset->close();
|
return false; |
}
|
|
foreach ($recordset as $record) {
|
\mod_forum\local\entities\post::add_message_counts($record);
|
$DB->update_record('forum_posts', $record); |
}
|
|
$recordscount = count($recordset);
|
$recordset->close();
|
|
return ($recordscount == $chunksize); |
}
|
Emitted during a cli cron job, which in turn emails me with the warning. Since it's buried within a cron task run, I'm not sure of the state which is required to reproduce the warning, but the recordset must not implement Countable, so this function probably needs a slight rewrite to clear the warning.