mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 14:18:52 +00:00
Merge branch 'ticket/14742' into ticket/14742-32x
This commit is contained in:
commit
210310b584
3 changed files with 38 additions and 4 deletions
|
@ -82,7 +82,7 @@ class migrator
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public $last_run_migration = false;
|
||||
protected $last_run_migration = false;
|
||||
|
||||
/**
|
||||
* The output handler. A null handler is configured by default.
|
||||
|
@ -162,6 +162,19 @@ class migrator
|
|||
$this->db->sql_return_on_error(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an array with information about the last migration run.
|
||||
*
|
||||
* The array contains 'name', 'class' and 'state'. 'effectively_installed' is set
|
||||
* and set to true if the last migration was effectively_installed.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get_last_run_migration()
|
||||
{
|
||||
return $this->last_run_migration;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the list of available migration class names to the given array.
|
||||
*
|
||||
|
@ -481,12 +494,15 @@ class migrator
|
|||
WHERE migration_name = '" . $this->db->sql_escape($name) . "'";
|
||||
$this->db->sql_query($sql);
|
||||
|
||||
$this->last_run_migration = false;
|
||||
unset($this->migration_state[$name]);
|
||||
|
||||
$this->output_handler->write(array('MIGRATION_REVERT_SCHEMA_DONE', $name, $elapsed_time), migrator_output_handler_interface::VERBOSITY_NORMAL);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->set_migration_state($name, $state);
|
||||
|
||||
$this->output_handler->write(array('MIGRATION_REVERT_SCHEMA_IN_PROGRESS', $name, $elapsed_time), migrator_output_handler_interface::VERBOSITY_VERY_VERBOSE);
|
||||
}
|
||||
}
|
||||
|
@ -513,6 +529,9 @@ class migrator
|
|||
$steps = array_reverse($steps);
|
||||
}
|
||||
|
||||
end($steps);
|
||||
$last_step_identifier = key($steps);
|
||||
|
||||
foreach ($steps as $step_identifier => $step)
|
||||
{
|
||||
$last_result = 0;
|
||||
|
@ -529,6 +548,12 @@ class migrator
|
|||
|
||||
// Set state to false since we reached the point we were at
|
||||
$state = false;
|
||||
|
||||
// There is a tendency to get stuck in some cases
|
||||
if ($last_result === null || $last_result === true)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
|
@ -537,7 +562,8 @@ class migrator
|
|||
// After any schema update step we allow to pause, since
|
||||
// database changes can take quite some time
|
||||
$result = $this->run_step($step, $last_result, $revert);
|
||||
if ($result !== null && $result !== true && strpos($step[0], 'dbtools') !== 0)
|
||||
if (($result !== null && $result !== true) ||
|
||||
(strpos($step[0], 'dbtools') === 0 && $step_identifier !== $last_step_identifier))
|
||||
{
|
||||
return serialize(array(
|
||||
'result' => $result,
|
||||
|
|
|
@ -36,13 +36,13 @@ class phpbb_dbal_migration_if extends \phpbb\db\migration\migration
|
|||
{
|
||||
global $migrator_test_if_true_failed;
|
||||
|
||||
$migrator_test_if_true_failed = false;
|
||||
$migrator_test_if_true_failed = !$migrator_test_if_true_failed;
|
||||
}
|
||||
|
||||
function test_false()
|
||||
{
|
||||
global $migrator_test_if_false_failed;
|
||||
|
||||
$migrator_test_if_false_failed = true;
|
||||
$migrator_test_if_false_failed = !$migrator_test_if_false_failed;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -154,6 +154,14 @@ class phpbb_dbal_migrator_test extends phpbb_database_test_case
|
|||
|
||||
$this->assertFalse($migrator_test_if_true_failed, 'True test failed');
|
||||
$this->assertFalse($migrator_test_if_false_failed, 'False test failed');
|
||||
|
||||
while ($this->migrator->migration_state('phpbb_dbal_migration_if') !== false)
|
||||
{
|
||||
$this->migrator->revert('phpbb_dbal_migration_if');
|
||||
}
|
||||
|
||||
$this->assertFalse($migrator_test_if_true_failed, 'True test after revert failed');
|
||||
$this->assertFalse($migrator_test_if_false_failed, 'False test after revert failed');
|
||||
}
|
||||
|
||||
public function test_recall()
|
||||
|
|
Loading…
Add table
Reference in a new issue