mirror of
https://github.com/phpbb/phpbb.git
synced 2025-04-13 12:22:03 +02:00
[ticket/14742] Enhance measured time for migrations
PHPBB3-14742
This commit is contained in:
parent
4a92a8efb5
commit
263fbe54fc
@ -152,6 +152,7 @@ class migrator
|
||||
$this->migration_state[$migration['migration_name']] = $migration;
|
||||
|
||||
$this->migration_state[$migration['migration_name']]['migration_depends_on'] = unserialize($migration['migration_depends_on']);
|
||||
$this->migration_state[$migration['migration_name']]['migration_data_state'] = !empty($migration['migration_data_state']) ? unserialize($migration['migration_data_state']) : '';
|
||||
}
|
||||
}
|
||||
|
||||
@ -315,17 +316,26 @@ class migrator
|
||||
$this->output_handler->write(array('MIGRATION_SCHEMA_RUNNING', $name), $verbosity);
|
||||
|
||||
$this->last_run_migration['task'] = 'process_schema_step';
|
||||
|
||||
$total_time = (is_array($state['migration_data_state']) && isset($state['migration_data_state']['_total_time'])) ?
|
||||
$state['migration_data_state']['_total_time'] : 0.0;
|
||||
$elapsed_time = microtime(true);
|
||||
$steps = $this->helper->get_schema_steps($migration->update_schema());
|
||||
$result = $this->process_data_step($steps, $state['migration_data_state']);
|
||||
$elapsed_time = microtime(true) - $elapsed_time;
|
||||
$total_time += $elapsed_time;
|
||||
|
||||
if (is_array($result))
|
||||
{
|
||||
$result['_total_time'] = $total_time;
|
||||
}
|
||||
|
||||
$state['migration_data_state'] = ($result === true) ? '' : $result;
|
||||
$state['migration_schema_done'] = ($result === true);
|
||||
|
||||
if ($state['migration_schema_done'])
|
||||
{
|
||||
$this->output_handler->write(array('MIGRATION_SCHEMA_DONE', $name, $elapsed_time), migrator_output_handler_interface::VERBOSITY_NORMAL);
|
||||
$this->output_handler->write(array('MIGRATION_SCHEMA_DONE', $name, $total_time), migrator_output_handler_interface::VERBOSITY_NORMAL);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -342,9 +352,17 @@ class migrator
|
||||
|
||||
$this->last_run_migration['task'] = 'process_data_step';
|
||||
|
||||
$total_time = (is_array($state['migration_data_state']) && isset($state['migration_data_state']['_total_time'])) ?
|
||||
$state['migration_data_state']['_total_time'] : 0.0;
|
||||
$elapsed_time = microtime(true);
|
||||
$result = $this->process_data_step($migration->update_data(), $state['migration_data_state']);
|
||||
$elapsed_time = microtime(true) - $elapsed_time;
|
||||
$total_time += $elapsed_time;
|
||||
|
||||
if (is_array($result))
|
||||
{
|
||||
$result['_total_time'] = $total_time;
|
||||
}
|
||||
|
||||
$state['migration_data_state'] = ($result === true) ? '' : $result;
|
||||
$state['migration_data_done'] = ($result === true);
|
||||
@ -352,7 +370,7 @@ class migrator
|
||||
|
||||
if ($state['migration_data_done'])
|
||||
{
|
||||
$this->output_handler->write(array('MIGRATION_DATA_DONE', $name, $elapsed_time), migrator_output_handler_interface::VERBOSITY_NORMAL);
|
||||
$this->output_handler->write(array('MIGRATION_DATA_DONE', $name, $total_time), migrator_output_handler_interface::VERBOSITY_NORMAL);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -484,7 +502,7 @@ class migrator
|
||||
*/
|
||||
protected function process_data_step($steps, $state, $revert = false)
|
||||
{
|
||||
$state = ($state) ? unserialize($state) : false;
|
||||
$state = is_array($state) ? $state : false;
|
||||
|
||||
// reverse order of steps if reverting
|
||||
if ($revert === true)
|
||||
@ -528,10 +546,10 @@ class migrator
|
||||
if (($result !== null && $result !== true) ||
|
||||
(strpos($step[0], 'dbtools') === 0 && $step_identifier !== $last_step_identifier))
|
||||
{
|
||||
return serialize(array(
|
||||
return array(
|
||||
'result' => $result,
|
||||
'step' => $step_identifier,
|
||||
));
|
||||
);
|
||||
}
|
||||
}
|
||||
catch (\phpbb\db\migration\exception $e)
|
||||
@ -702,6 +720,7 @@ class migrator
|
||||
{
|
||||
$migration_row = $state;
|
||||
$migration_row['migration_depends_on'] = serialize($state['migration_depends_on']);
|
||||
$migration_row['migration_data_state'] = !empty($state['migration_data_state']) ? serialize($state['migration_data_state']) : '';
|
||||
|
||||
if (isset($this->migration_state[$name]))
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user