Пример #1
0
 /**
  * {@inheritdoc}
  */
 public function run()
 {
     // Recover install progress
     $task_name = $this->recover_progress();
     $task_found = false;
     /**
      * @var string							$name	ID of the service
      * @var \phpbb\install\task_interface	$task	Task object
      */
     foreach ($this->task_collection as $name => $task) {
         // Run until there are available resources
         if ($this->install_config->get_time_remaining() <= 0 || $this->install_config->get_memory_remaining() <= 0) {
             throw new resource_limit_reached_exception();
         }
         // Skip forward until the next task is reached
         if (!$task_found) {
             if ($name === $task_name || empty($task_name)) {
                 $task_found = true;
                 if ($name === $task_name) {
                     continue;
                 }
             } else {
                 continue;
             }
         }
         // Send progress information
         if ($this->allow_progress_bar) {
             $this->iohandler->set_progress($task->get_task_lang_name(), $this->install_config->get_current_task_progress());
         }
         // Check if we can run the task
         if (!$task->is_essential() && !$task->check_requirements()) {
             $this->iohandler->add_log_message(array('SKIP_TASK', $name));
             $this->install_config->increment_current_task_progress($this->task_step_count[$name]);
             continue;
         }
         if ($this->allow_progress_bar) {
             // Only increment progress by one, as if a task has more than one steps
             // then that should be incremented in the task itself
             $this->install_config->increment_current_task_progress();
         }
         $task->run();
         // Log install progress
         $this->install_config->set_finished_task($name);
         // Send progress information
         if ($this->allow_progress_bar) {
             $this->iohandler->set_progress($task->get_task_lang_name(), $this->install_config->get_current_task_progress());
         }
         $this->iohandler->send_response();
     }
     // Module finished, so clear task progress
     $this->install_config->set_finished_task('');
 }
Пример #2
0
 /**
  * {@inheritdoc}
  */
 public function run()
 {
     // Recover install progress
     $task_index = $this->recover_progress();
     $iterator = $this->task_collection->getIterator();
     if ($task_index < $iterator->count()) {
         $iterator->seek($task_index);
     } else {
         $this->install_config->set_finished_task(0);
         return;
     }
     while ($iterator->valid()) {
         $task = $iterator->current();
         $name = $iterator->key();
         // Check if we can run the task
         if (!$task->is_essential() && !$task->check_requirements()) {
             $this->iohandler->add_log_message(array('SKIP_TASK', $name));
             $this->install_config->increment_current_task_progress($this->task_step_count[$name]);
         } else {
             // Send progress information
             if ($this->allow_progress_bar) {
                 $this->iohandler->set_progress($task->get_task_lang_name(), $this->install_config->get_current_task_progress());
                 $this->iohandler->send_response();
             }
             $task->run();
             if ($this->allow_progress_bar) {
                 // Only increment progress by one, as if a task has more than one steps
                 // then that should be incremented in the task itself
                 $this->install_config->increment_current_task_progress();
             }
         }
         $task_index++;
         $this->install_config->set_finished_task($task_index);
         $iterator->next();
         // Send progress information
         if ($this->allow_progress_bar) {
             $this->iohandler->set_progress($task->get_task_lang_name(), $this->install_config->get_current_task_progress());
         }
         $this->iohandler->send_response();
         // Stop execution if resource limit is reached
         if ($this->install_config->get_time_remaining() <= 0 || $this->install_config->get_memory_remaining() <= 0) {
             throw new resource_limit_reached_exception();
         }
     }
     // Module finished, so clear task progress
     $this->install_config->set_finished_task(0);
 }