mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-12 06:18:52 +00:00
[ticket/13064] Validate the migrations provided to migrator::set_migrations()
PHPBB3-13064
This commit is contained in:
parent
48dbef391b
commit
46a9fe93d7
2 changed files with 27 additions and 2 deletions
|
@ -129,11 +129,28 @@ class migrator
|
||||||
* Sets the list of available migration class names to the given array.
|
* Sets the list of available migration class names to the given array.
|
||||||
*
|
*
|
||||||
* @param array $class_names An array of migration class names
|
* @param array $class_names An array of migration class names
|
||||||
|
* @param bool $check_fulfillable If TRUE (default), we will check
|
||||||
|
* if all of the migrations are fulfillable after loading them.
|
||||||
|
* If FALSE, we will not check. You SHOULD check at least once
|
||||||
|
* to prevent errors.
|
||||||
* @return null
|
* @return null
|
||||||
|
* @throws \phpbb\db\migration\exception
|
||||||
*/
|
*/
|
||||||
public function set_migrations($class_names)
|
public function set_migrations($class_names, $check_fulfillable = true)
|
||||||
{
|
{
|
||||||
$this->migrations = $class_names;
|
$this->migrations = $class_names;
|
||||||
|
|
||||||
|
if ($check_fulfillable)
|
||||||
|
{
|
||||||
|
foreach ($this->migrations as $name)
|
||||||
|
{
|
||||||
|
$unfulfillable = $this->unfulfillable($name);
|
||||||
|
if ($unfulfillable !== false)
|
||||||
|
{
|
||||||
|
throw new \phpbb\db\migration\exception('MIGRATION_NOT_FULFILLABLE', $name, $unfulfillable);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -118,9 +118,17 @@ class phpbb_dbal_migrator_test extends phpbb_database_test_case
|
||||||
$this->db_tools->sql_column_remove('phpbb_config', 'extra_column');
|
$this->db_tools->sql_column_remove('phpbb_config', 'extra_column');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_unfulfillable()
|
/**
|
||||||
|
* @expectedException \phpbb\db\migration\exception
|
||||||
|
*/
|
||||||
|
public function test_unfulfillable_exception()
|
||||||
{
|
{
|
||||||
$this->migrator->set_migrations(array('phpbb_dbal_migration_unfulfillable', 'phpbb_dbal_migration_dummy'));
|
$this->migrator->set_migrations(array('phpbb_dbal_migration_unfulfillable', 'phpbb_dbal_migration_dummy'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_unfulfillable()
|
||||||
|
{
|
||||||
|
$this->migrator->set_migrations(array('phpbb_dbal_migration_unfulfillable', 'phpbb_dbal_migration_dummy'), false);
|
||||||
|
|
||||||
while (!$this->migrator->finished())
|
while (!$this->migrator->finished())
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue