diff options
author | Nathan Guse <nathaniel.guse@gmail.com> | 2013-01-09 17:20:12 -0600 |
---|---|---|
committer | Nathan Guse <nathaniel.guse@gmail.com> | 2013-01-09 17:20:12 -0600 |
commit | 79818c2139c305147d53ffb7217bec7568ff8b9c (patch) | |
tree | 0bd855c6ea8397a0cd4dcec7e46525190b222044 | |
parent | 5f9e1f1e89f8df5420fd82b5256a461de0f98604 (diff) | |
download | forums-79818c2139c305147d53ffb7217bec7568ff8b9c.tar forums-79818c2139c305147d53ffb7217bec7568ff8b9c.tar.gz forums-79818c2139c305147d53ffb7217bec7568ff8b9c.tar.bz2 forums-79818c2139c305147d53ffb7217bec7568ff8b9c.tar.xz forums-79818c2139c305147d53ffb7217bec7568ff8b9c.zip |
[feature/migrations] Stop the update process if we are approaching time limit
PHPBB3-9737
-rw-r--r-- | phpBB/test.php | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/phpBB/test.php b/phpBB/test.php index 5887c08d2f..ed4c1928ee 100644 --- a/phpBB/test.php +++ b/phpBB/test.php @@ -7,6 +7,8 @@ * */ +$update_start_time = time(); + use Symfony\Component\Config\FileLocator; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; @@ -42,18 +44,6 @@ set_error_handler(defined('PHPBB_MSG_HANDLER') ? PHPBB_MSG_HANDLER : 'msg_handle $phpbb_class_loader = new phpbb_class_loader('phpbb_', "{$phpbb_root_path}includes/", ".$phpEx"); $phpbb_class_loader->register(); -/*$phpbb_container = phpbb_create_container( - array( - new phpbb_di_extension_config($phpbb_root_path . 'config.' . $phpEx), - new phpbb_di_extension_core($phpbb_root_path), - ), - array( - new phpbb_di_pass_collection_pass(), - new phpbb_di_pass_kernel_pass(), - ), - $phpbb_root_path, $phpEx); -$phpbb_container->compile();*/ - // Set up container $container_extensions = array( new phpbb_di_extension_config($phpbb_root_path . 'config.' . $phpEx), @@ -111,11 +101,27 @@ if (!$db_tools->sql_table_exists(MIGRATIONS_TABLE)) $migrator = $phpbb_container->get('migrator'); $migrator->load_migrations($phpbb_root_path . 'includes/db/migration/data/'); +$safe_time_limit = (ini_get('max_execution_time') / 2); + while (!$migrator->finished()) { $migrator->update(); echo $migrator->last_run_migration['name'] . '<br />'; + + // Are we approaching the time limit? If so we want to pause the update and continue after refreshing + if ((time() - $update_start_time) >= $safe_time_limit) + { + //echo '<meta http-equiv="refresh" content="0;url=' . str_replace('&', '&', append_sid($phpbb_root_path . 'test.' . $phpEx)) . '" />'; + echo 'Update not yet completed.<br />'; + echo '<a href="' . append_sid($phpbb_root_path . 'test.' . $phpEx) . '">Continue</a>'; + + garbage_collection(); + exit_handler(); + } } echo 'Finished'; + +garbage_collection(); +exit_handler(); |