1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-07-30 21:40:43 +02:00

[ticket/13740] Fix itteration problems, implement class name aware collections

PHPBB3-13740
This commit is contained in:
Mate Bartus
2015-07-09 19:08:28 +02:00
parent b284e31a9e
commit e967f3c1a8
12 changed files with 88 additions and 83 deletions

View File

@@ -13,6 +13,7 @@
namespace phpbb\install\module\requirements;
use phpbb\install\exception\resource_limit_reached_exception;
use phpbb\install\exception\user_interaction_required_exception;
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
@@ -23,30 +24,38 @@ class module extends \phpbb\install\module_base
$tests_passed = true;
// Recover install progress
$task_index = 0;
$task_name = $this->recover_progress();
$task_found = false;
// Run until there are available resources
while ($this->install_config->get_time_remaining() > 0 && $this->install_config->get_memory_remaining() > 0)
/**
* @var string $name ID of the service
* @var \phpbb\install\task_interface $task Task object
*/
foreach ($this->task_collection as $name => $task)
{
// Check if task exists
if (!isset($this->task_collection[$task_index]))
// Run until there are available resources
if ($this->install_config->get_time_remaining() <= 0 && $this->install_config->get_memory_remaining() <= 0)
{
break;
throw new resource_limit_reached_exception();
}
// Recover task to be executed
try
// Skip forward until the next task is reached
if (!$task_found)
{
/** @var \phpbb\install\task_interface $task */
$task = $this->container->get($this->task_collection[$task_index]);
}
catch (InvalidArgumentException $e)
{
throw new task_not_found_exception($this->task_collection[$task_index]);
}
if ($name === $task_name || empty($task_name))
{
$task_found = true;
// Iterate to the next task
$task_index++;
if ($name === $task_name)
{
continue;
}
}
else
{
continue;
}
}
// Check if we can run the task
if (!$task->is_essential() && !$task->check_requirements())
@@ -54,10 +63,18 @@ class module extends \phpbb\install\module_base
continue;
}
if ($this->allow_progress_bar)
{
$this->install_config->increment_current_task_progress();
}
$test_result = $task->run();
$tests_passed = ($tests_passed) ? $test_result : false;
}
// Module finished, so clear task progress
$this->install_config->set_finished_task('');
// Check if tests have failed
if (!$tests_passed)
{
@@ -74,10 +91,6 @@ class module extends \phpbb\install\module_base
$this->iohandler->send_response();
throw new user_interaction_required_exception();
}
// Log install progress
$current_task_index = $task_index - 1;
$this->install_config->set_finished_task($this->task_collection[$current_task_index], $current_task_index);
}
/**