aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/phpbb/db/migrator.php
diff options
context:
space:
mode:
authorOliver Schramm <oliver.schramm97@gmail.com>2016-08-12 02:03:52 +0200
committerOliver Schramm <oliver.schramm97@gmail.com>2016-08-12 02:03:52 +0200
commit263fbe54fcf03fe55f738146d7c6359108a4b48f (patch)
tree233bd2da4a97421c50126b0336362d651c7bd910 /phpBB/phpbb/db/migrator.php
parent4a92a8efb549c740f61655836f85de9be5c5b548 (diff)
downloadforums-263fbe54fcf03fe55f738146d7c6359108a4b48f.tar
forums-263fbe54fcf03fe55f738146d7c6359108a4b48f.tar.gz
forums-263fbe54fcf03fe55f738146d7c6359108a4b48f.tar.bz2
forums-263fbe54fcf03fe55f738146d7c6359108a4b48f.tar.xz
forums-263fbe54fcf03fe55f738146d7c6359108a4b48f.zip
[ticket/14742] Enhance measured time for migrations
PHPBB3-14742
Diffstat (limited to 'phpBB/phpbb/db/migrator.php')
-rw-r--r--phpBB/phpbb/db/migrator.php29
1 files changed, 24 insertions, 5 deletions
diff --git a/phpBB/phpbb/db/migrator.php b/phpBB/phpbb/db/migrator.php
index eb3bc7eaf5..65db4b74bf 100644
--- a/phpBB/phpbb/db/migrator.php
+++ b/phpBB/phpbb/db/migrator.php
@@ -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]))
{