From f6d9b81ebce41721dba5a53d148c8076cd67a7aa Mon Sep 17 00:00:00 2001 From: Andrew Nicols Date: Tue, 14 Mar 2023 10:25:04 +0800 Subject: [PATCH] MDL-77186 core: Address coding style violations in cron --- lib/classes/cron.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/classes/cron.php b/lib/classes/cron.php index 3c57aef68de..79b7bbc7240 100644 --- a/lib/classes/cron.php +++ b/lib/classes/cron.php @@ -21,6 +21,10 @@ use core_php_time_limit; use moodle_exception; use stdClass; +// Disable the moodle.PHP.ForbiddenFunctions.FoundWithAlternative sniff for this file. +// It detects uses of error_log() which are valid in this file. +// phpcs:disable moodle.PHP.ForbiddenFunctions.FoundWithAlternative + /** * Cron and adhoc task functionality. * @@ -86,7 +90,7 @@ class cron { self::setup_user(); // Start output log. - $timenow = time(); + $timenow = time(); mtrace("Server Time: " . date('r', $timenow) . "\n\n"); // Record start time and interval between the last cron runs. @@ -394,7 +398,7 @@ class cron { self::trace_time_and_memory(); $predbqueries = null; $predbqueries = $DB->perf_get_queries(); - $pretime = microtime(1); + $pretime = microtime(1); if ($userid = $task->get_userid()) { // This task has a userid specified. @@ -413,8 +417,8 @@ class cron { } if (empty($user)) { - // A user missing in the database will never reappear so the task needs to be failed to ensure that locks are removed, - // and then removed to prevent future runs. + // A user missing in the database will never reappear so the task needs to be failed to ensure that locks are + // removed, and then removed to prevent future runs. // A task running as a user should only be run as that user. \core\task\manager::adhoc_task_failed($task); $DB->delete_records('task_adhoc', ['id' => $task->get_id()]);