aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/phpbb/install/module_base.php
diff options
context:
space:
mode:
authorTristan Darricau <tristan.darricau@sensiolabs.com>2016-02-16 00:11:27 +0100
committerTristan Darricau <tristan.darricau@sensiolabs.com>2016-02-16 00:11:27 +0100
commit8d1eee0e0118510def943e43e3246b2b89a08bdc (patch)
tree478bf6c878bacec7c4e60832e0af7d106bd52e52 /phpBB/phpbb/install/module_base.php
parent1f0b6c8123cdecf2f5f1855ad52a90ef962809a4 (diff)
parentd0ce6a18df2172a6e9baf1f1c2802efb30b25323 (diff)
downloadforums-8d1eee0e0118510def943e43e3246b2b89a08bdc.tar
forums-8d1eee0e0118510def943e43e3246b2b89a08bdc.tar.gz
forums-8d1eee0e0118510def943e43e3246b2b89a08bdc.tar.bz2
forums-8d1eee0e0118510def943e43e3246b2b89a08bdc.tar.xz
forums-8d1eee0e0118510def943e43e3246b2b89a08bdc.zip
Merge branch '3.2.x'
* 3.2.x: [ticket/14462] Not show timeout messages in convertors [ticket/14462] Make timeout error translateable [ticket/14462] Update ordering in install db config [ticket/14462] Fix comments [ticket/14462] Fix tests [ticket/14462] Fix CS and typo [ticket/14462] Set instance of db driver for database access using global [ticket/14462] Fix installation in tests [ticket/14462] Refactor tasks to be more modular [ticket/14462] Further speed improvements
Diffstat (limited to 'phpBB/phpbb/install/module_base.php')
-rw-r--r--phpBB/phpbb/install/module_base.php97
1 files changed, 46 insertions, 51 deletions
diff --git a/phpBB/phpbb/install/module_base.php b/phpBB/phpbb/install/module_base.php
index fb68c3aca2..527447b4a1 100644
--- a/phpBB/phpbb/install/module_base.php
+++ b/phpBB/phpbb/install/module_base.php
@@ -105,47 +105,23 @@ abstract class module_base implements module_interface
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();
- }
+ $task_index = $this->recover_progress();
+ $iterator = $this->task_collection->getIterator();
- // 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;
- }
- }
+ if ($task_index < $iterator->count())
+ {
+ $iterator->seek($task_index);
+ }
+ else
+ {
+ $this->install_config->set_finished_task(0);
+ return;
+ }
- // Send progress information
- if ($this->allow_progress_bar)
- {
- $this->iohandler->set_progress(
- $task->get_task_lang_name(),
- $this->install_config->get_current_task_progress()
- );
- }
+ while ($iterator->valid())
+ {
+ $task = $iterator->current();
+ $name = $iterator->key();
// Check if we can run the task
if (!$task->is_essential() && !$task->check_requirements())
@@ -156,20 +132,33 @@ abstract class module_base implements module_interface
));
$this->install_config->increment_current_task_progress($this->task_step_count[$name]);
- continue;
}
-
- if ($this->allow_progress_bar)
+ else
{
- // 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();
- }
+ // 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();
- $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();
+ }
+ }
- // Log install progress
- $this->install_config->set_finished_task($name);
+ $task_index++;
+ $this->install_config->set_finished_task($task_index);
+ $iterator->next();
// Send progress information
if ($this->allow_progress_bar)
@@ -181,10 +170,16 @@ abstract class module_base implements module_interface
}
$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('');
+ $this->install_config->set_finished_task(0);
}
/**
@@ -195,7 +190,7 @@ abstract class module_base implements module_interface
protected function recover_progress()
{
$progress_array = $this->install_config->get_progress_data();
- return $progress_array['last_task_name'];
+ return $progress_array['last_task_index'];
}
/**