mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-27 21:58:52 +00:00
[ticket/11415] Move while loop from ext manager to acp_extensions.php
Now enable_step works as it's supposed to (do one step at a time) and less refreshes are required for the user. PHPBB3-11415
This commit is contained in:
parent
c182ab0e7b
commit
9db4e856db
2 changed files with 28 additions and 27 deletions
|
@ -44,6 +44,10 @@ class acp_extensions
|
||||||
$action = $request->variable('action', 'list');
|
$action = $request->variable('action', 'list');
|
||||||
$ext_name = $request->variable('ext_name', '');
|
$ext_name = $request->variable('ext_name', '');
|
||||||
|
|
||||||
|
// What is a safe limit of execution time? Half the max execution time should be safe.
|
||||||
|
$safe_time_limit = (ini_get('max_execution_time') / 2);
|
||||||
|
$start_time = time();
|
||||||
|
|
||||||
// Cancel action
|
// Cancel action
|
||||||
if ($request->is_set_post('cancel'))
|
if ($request->is_set_post('cancel'))
|
||||||
{
|
{
|
||||||
|
@ -105,11 +109,15 @@ class acp_extensions
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if ($phpbb_extension_manager->enable_step($ext_name))
|
while ($phpbb_extension_manager->enable_step($ext_name))
|
||||||
{
|
{
|
||||||
$template->assign_var('S_NEXT_STEP', true);
|
// Are we approaching the time limit? If so we want to pause the update and continue after refreshing
|
||||||
|
if ((time() - $start_time) >= $safe_time_limit)
|
||||||
|
{
|
||||||
|
$template->assign_var('S_NEXT_STEP', true);
|
||||||
|
|
||||||
meta_refresh(0, $this->u_action . '&action=enable&ext_name=' . urlencode($ext_name));
|
meta_refresh(0, $this->u_action . '&action=enable&ext_name=' . urlencode($ext_name));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (phpbb_db_migration_exception $e)
|
catch (phpbb_db_migration_exception $e)
|
||||||
|
@ -139,11 +147,15 @@ class acp_extensions
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'disable':
|
case 'disable':
|
||||||
if ($phpbb_extension_manager->disable_step($ext_name))
|
while ($phpbb_extension_manager->disable_step($ext_name))
|
||||||
{
|
{
|
||||||
$template->assign_var('S_NEXT_STEP', true);
|
// Are we approaching the time limit? If so we want to pause the update and continue after refreshing
|
||||||
|
if ((time() - $start_time) >= $safe_time_limit)
|
||||||
|
{
|
||||||
|
$template->assign_var('S_NEXT_STEP', true);
|
||||||
|
|
||||||
meta_refresh(0, $this->u_action . '&action=disable&ext_name=' . urlencode($ext_name));
|
meta_refresh(0, $this->u_action . '&action=disable&ext_name=' . urlencode($ext_name));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->tpl_name = 'acp_ext_disable';
|
$this->tpl_name = 'acp_ext_disable';
|
||||||
|
@ -165,11 +177,15 @@ class acp_extensions
|
||||||
case 'purge':
|
case 'purge':
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if ($phpbb_extension_manager->purge_step($ext_name))
|
while ($phpbb_extension_manager->purge_step($ext_name))
|
||||||
{
|
{
|
||||||
$template->assign_var('S_NEXT_STEP', true);
|
// Are we approaching the time limit? If so we want to pause the update and continue after refreshing
|
||||||
|
if ((time() - $start_time) >= $safe_time_limit)
|
||||||
|
{
|
||||||
|
$template->assign_var('S_NEXT_STEP', true);
|
||||||
|
|
||||||
meta_refresh(0, $this->u_action . '&action=purge&ext_name=' . urlencode($ext_name));
|
meta_refresh(0, $this->u_action . '&action=purge&ext_name=' . urlencode($ext_name));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (phpbb_db_migration_exception $e)
|
catch (phpbb_db_migration_exception $e)
|
||||||
|
|
|
@ -546,22 +546,11 @@ class phpbb_extension_manager
|
||||||
$migrations = $finder->get_classes_from_files($migrations);
|
$migrations = $finder->get_classes_from_files($migrations);
|
||||||
$this->migrator->set_migrations($migrations);
|
$this->migrator->set_migrations($migrations);
|
||||||
|
|
||||||
// What is a safe limit of execution time? Half the max execution time should be safe.
|
|
||||||
$safe_time_limit = (ini_get('max_execution_time') / 2);
|
|
||||||
$start_time = time();
|
|
||||||
|
|
||||||
if ($mode == 'enable')
|
if ($mode == 'enable')
|
||||||
{
|
{
|
||||||
while (!$this->migrator->finished())
|
$this->migrator->update();
|
||||||
{
|
|
||||||
$this->migrator->update();
|
|
||||||
|
|
||||||
// Are we approaching the time limit? If so we want to pause the update and continue after refreshing
|
return $this->migrator->finished();
|
||||||
if ((time() - $start_time) >= $safe_time_limit)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if ($mode == 'purge')
|
else if ($mode == 'purge')
|
||||||
{
|
{
|
||||||
|
@ -571,11 +560,7 @@ class phpbb_extension_manager
|
||||||
{
|
{
|
||||||
$this->migrator->revert($migration);
|
$this->migrator->revert($migration);
|
||||||
|
|
||||||
// Are we approaching the time limit? If so we want to pause the update and continue after refreshing
|
return false;
|
||||||
if ((time() - $start_time) >= $safe_time_limit)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue