original_string: public static function reschedule_or_queue_adhoc_task(adhoc_task $task) : void {
          global $DB;
  
          if ($existingrecord = self::get_queued_adhoc_task_record($task)) {
              // Only update the next run time if it is explicitly set on the task.
              $nextruntime = $task->get_next_run_time();
              if ($nextruntime && ($existingrecord->nextruntime != $nextruntime)) {
                  $DB->set_field('task_adhoc', 'nextruntime', $nextruntime, ['id' => $existingrecord->id]);
              }
          } else {
              // There is nothing queued yet. Just queue as normal.
              self::queue_adhoc_task($task);
          }
      }
code: public static function reschedule_or_queue_adhoc_task(adhoc_task $task) : void {
          global $DB;
  
          if ($existingrecord = self::get_queued_adhoc_task_record($task)) {
              // Only update the next run time if it is explicitly set on the task.
              $nextruntime = $task->get_next_run_time();
              if ($nextruntime && ($existingrecord->nextruntime != $nextruntime)) {
                  $DB->set_field('task_adhoc', 'nextruntime', $nextruntime, ['id' => $existingrecord->id]);
              }
          } else {
              // There is nothing queued yet. Just queue as normal.
              self::queue_adhoc_task($task);
          }
      }
code_tokens: public static function reschedule_or_queue_adhoc_task ( adhoc_task $ task ) : void { global $ DB ; if ( $ existingrecord = self :: get_queued_adhoc_task_record ( $ task ) ) { // Only update the next run time if it is explicitly set on the task. $ nextruntime = $ task -> get_next_run_time ( ) ; if ( $ nextruntime && ( $ existingrecord -> nextruntime != $ nextruntime ) ) { $ DB -> set_field ( 'task_adhoc' , 'nextruntime' , $ nextruntime , [ 'id' => $ existingrecord -> id ] ) ; } } else { // There is nothing queued yet. Just queue as normal. self :: queue_adhoc_task ( $ task ) ; } }
docstring: Schedule a new task, or reschedule an existing adhoc task which has matching data.
  
  Only a task matching the same user, classname, component, and customdata will be rescheduled.
  If these values do not match exactly then a new task is scheduled.
  
  @param \core\task\adhoc_task $task - The new adhoc task information to store.
  @since Moodle 3.7
docstring_tokens: Schedule a new task or reschedule an existing adhoc task which has matching data .