original_string: public function run()
      {
          $tasks = $this->loader->loadTasks();
  
          $this->logger->debug('{count} scheduled tasks loaded', array('count' => count($tasks)));
  
          // remove from timetable tasks that are not active anymore
          $this->timetable->removeInactiveTasks($tasks);
  
          $this->logger->info("Starting Scheduled tasks... ");
  
          // for every priority level, starting with the highest and concluding with the lowest
          $executionResults = array();
          for ($priority = Task::HIGHEST_PRIORITY; $priority <= Task::LOWEST_PRIORITY; ++$priority) {
              $this->logger->debug("Executing tasks with priority {priority}:", array('priority' => $priority));
  
              // loop through each task
              foreach ($tasks as $task) {
                  // if the task does not have the current priority level, don't execute it yet
                  if ($task->getPriority() != $priority) {
                      continue;
                  }
  
                  $taskName = $task->getName();
                  $shouldExecuteTask = $this->timetable->shouldExecuteTask($taskName);
  
                  if ($this->timetable->taskShouldBeRescheduled($taskName)) {
                      $rescheduledDate = $this->timetable->rescheduleTask($task);
  
                      $this->logger->debug("Task {task} is scheduled to run again for {date}.", array('task' => $taskName, 'date' => $rescheduledDate));
                  }
  
                  /**
                   * Triggered before a task is executed.
                   *
                   * A plugin can listen to it and modify whether a specific task should be executed or not. This way
                   * you can force certain tasks to be executed more often or for example to be never executed.
                   *
                   * @param bool &$shouldExecuteTask Decides whether the task will be executed.
                   * @param Task $task The task that is about to be executed.
                   */
                  Piwik::postEvent('ScheduledTasks.shouldExecuteTask', array(&$shouldExecuteTask, $task));
  
                  if ($shouldExecuteTask) {
                      $message = $this->executeTask($task);
  
                      $executionResults[] = array('task' => $taskName, 'output' => $message);
                  }
              }
          }
  
          $this->logger->info("done");
  
          return $executionResults;
      }
code: public function run()
      {
          $tasks = $this->loader->loadTasks();
  
          $this->logger->debug('{count} scheduled tasks loaded', array('count' => count($tasks)));
  
          // remove from timetable tasks that are not active anymore
          $this->timetable->removeInactiveTasks($tasks);
  
          $this->logger->info("Starting Scheduled tasks... ");
  
          // for every priority level, starting with the highest and concluding with the lowest
          $executionResults = array();
          for ($priority = Task::HIGHEST_PRIORITY; $priority <= Task::LOWEST_PRIORITY; ++$priority) {
              $this->logger->debug("Executing tasks with priority {priority}:", array('priority' => $priority));
  
              // loop through each task
              foreach ($tasks as $task) {
                  // if the task does not have the current priority level, don't execute it yet
                  if ($task->getPriority() != $priority) {
                      continue;
                  }
  
                  $taskName = $task->getName();
                  $shouldExecuteTask = $this->timetable->shouldExecuteTask($taskName);
  
                  if ($this->timetable->taskShouldBeRescheduled($taskName)) {
                      $rescheduledDate = $this->timetable->rescheduleTask($task);
  
                      $this->logger->debug("Task {task} is scheduled to run again for {date}.", array('task' => $taskName, 'date' => $rescheduledDate));
                  }
  
                  /**
                   * Triggered before a task is executed.
                   *
                   * A plugin can listen to it and modify whether a specific task should be executed or not. This way
                   * you can force certain tasks to be executed more often or for example to be never executed.
                   *
                   * @param bool &$shouldExecuteTask Decides whether the task will be executed.
                   * @param Task $task The task that is about to be executed.
                   */
                  Piwik::postEvent('ScheduledTasks.shouldExecuteTask', array(&$shouldExecuteTask, $task));
  
                  if ($shouldExecuteTask) {
                      $message = $this->executeTask($task);
  
                      $executionResults[] = array('task' => $taskName, 'output' => $message);
                  }
              }
          }
  
          $this->logger->info("done");
  
          return $executionResults;
      }
code_tokens: public function run ( ) { $ tasks = $ this -> loader -> loadTasks ( ) ; $ this -> logger -> debug ( '{count} scheduled tasks loaded' , array ( 'count' => count ( $ tasks ) ) ) ; // remove from timetable tasks that are not active anymore $ this -> timetable -> removeInactiveTasks ( $ tasks ) ; $ this -> logger -> info ( "Starting Scheduled tasks... " ) ; // for every priority level, starting with the highest and concluding with the lowest $ executionResults = array ( ) ; for ( $ priority = Task :: HIGHEST_PRIORITY ; $ priority <= Task :: LOWEST_PRIORITY ; ++ $ priority ) { $ this -> logger -> debug ( "Executing tasks with priority {priority}:" , array ( 'priority' => $ priority ) ) ; // loop through each task foreach ( $ tasks as $ task ) { // if the task does not have the current priority level, don't execute it yet if ( $ task -> getPriority ( ) != $ priority ) { continue ; } $ taskName = $ task -> getName ( ) ; $ shouldExecuteTask = $ this -> timetable -> shouldExecuteTask ( $ taskName ) ; if ( $ this -> timetable -> taskShouldBeRescheduled ( $ taskName ) ) { $ rescheduledDate = $ this -> timetable -> rescheduleTask ( $ task ) ; $ this -> logger -> debug ( "Task {task} is scheduled to run again for {date}." , array ( 'task' => $ taskName , 'date' => $ rescheduledDate ) ) ; } /**
                   * Triggered before a task is executed.
                   *
                   * A plugin can listen to it and modify whether a specific task should be executed or not. This way
                   * you can force certain tasks to be executed more often or for example to be never executed.
                   *
                   * @param bool &$shouldExecuteTask Decides whether the task will be executed.
                   * @param Task $task The task that is about to be executed.
                   */ Piwik :: postEvent ( 'ScheduledTasks.shouldExecuteTask' , array ( & $ shouldExecuteTask , $ task ) ) ; if ( $ shouldExecuteTask ) { $ message = $ this -> executeTask ( $ task ) ; $ executionResults [ ] = array ( 'task' => $ taskName , 'output' => $ message ) ; } } } $ this -> logger -> info ( "done" ) ; return $ executionResults ; }
docstring: Executes tasks that are scheduled to run, then reschedules them.
  
  @return array An array describing the results of scheduled task execution. Each element
  in the array will have the following format:
  
  ```
  array(
  'task' => 'task name',
  'output' => '... task output ...'
  )
  ```
docstring_tokens: Executes tasks that are scheduled to run then reschedules them .