aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB
diff options
context:
space:
mode:
authorMatt Friedman <maf675@gmail.com>2016-01-27 11:46:04 -0800
committerMatt Friedman <maf675@gmail.com>2016-01-27 11:46:04 -0800
commit3bd8a2ba196f240c5b982271af1ee8b2a2f8332b (patch)
tree8c3fa9178348ba1772103f2e78fa3c22b3b8ceef /phpBB
parent47d8aeebde6f763ec7247daf0df16dd2388b25b6 (diff)
downloadforums-3bd8a2ba196f240c5b982271af1ee8b2a2f8332b.tar
forums-3bd8a2ba196f240c5b982271af1ee8b2a2f8332b.tar.gz
forums-3bd8a2ba196f240c5b982271af1ee8b2a2f8332b.tar.bz2
forums-3bd8a2ba196f240c5b982271af1ee8b2a2f8332b.tar.xz
forums-3bd8a2ba196f240c5b982271af1ee8b2a2f8332b.zip
[ticket/14434] Remove recursion to simplify is_migration method
PHPBB3-14434
Diffstat (limited to 'phpBB')
-rw-r--r--phpBB/phpbb/db/migration/schema_generator.php3
-rw-r--r--phpBB/phpbb/db/migrator.php27
-rw-r--r--phpBB/phpbb/extension/base.php13
3 files changed, 17 insertions, 26 deletions
diff --git a/phpBB/phpbb/db/migration/schema_generator.php b/phpBB/phpbb/db/migration/schema_generator.php
index dc685bb161..c579e25824 100644
--- a/phpBB/phpbb/db/migration/schema_generator.php
+++ b/phpBB/phpbb/db/migration/schema_generator.php
@@ -79,8 +79,7 @@ class schema_generator
{
foreach ($migrations as $key => $migration_class)
{
- // Unset classes that do not exist or do not extend the
- // abstract class phpbb\db\migration\migration
+ // Unset classes that are not a valid migration
if (\phpbb\db\migrator::is_migration($migration_class) === false)
{
unset($migrations[$key]);
diff --git a/phpBB/phpbb/db/migrator.php b/phpBB/phpbb/db/migrator.php
index 563958b258..2f280ec5a5 100644
--- a/phpBB/phpbb/db/migrator.php
+++ b/phpBB/phpbb/db/migrator.php
@@ -861,31 +861,16 @@ class migrator
/**
* Check if a class is a migration.
*
- * @param mixed $migration An array of migration name strings, or
- * a single migration name string.
- * @return bool Returns true or false for a single migration.
- * If an array was received, non-migrations will
- * be removed from the array, and false is returned.
+ * @param string $migration A migration class name
+ * @return bool Return true if class is a migration, false otherwise
*/
- static public function is_migration(&$migration)
+ static public function is_migration($migration)
{
- if (is_array($migration))
- {
- foreach ($migration as $key => $name)
- {
- if (self::is_migration($name))
- {
- continue;
- }
-
- unset($migration[$key]);
- }
- }
- else if (class_exists($migration))
+ if (class_exists($migration))
{
// Migration classes should extend the abstract class
- // phpbb\db\migration\migration which implements the
- // migration_interface and be instantiable.
+ // phpbb\db\migration\migration (which implements the
+ // migration_interface) and be instantiable.
$reflector = new \ReflectionClass($migration);
if ($reflector->implementsInterface('\phpbb\db\migration\migration_interface') && $reflector->isInstantiable())
{
diff --git a/phpBB/phpbb/extension/base.php b/phpBB/phpbb/extension/base.php
index b05c1af8d4..abdb10df88 100644
--- a/phpBB/phpbb/extension/base.php
+++ b/phpBB/phpbb/extension/base.php
@@ -137,9 +137,16 @@ class base implements \phpbb\extension\extension_interface
$migrations = $this->extension_finder->get_classes_from_files($migrations);
- // Unset classes that do not exist or do not extend the
- // abstract class phpbb\db\migration\migration
- \phpbb\db\migrator::is_migration($migrations);
+ // Unset classes that are not a valid migration
+ foreach ($migrations as $key => $migration)
+ {
+ if (\phpbb\db\migrator::is_migration($migration) === true)
+ {
+ continue;
+ }
+
+ unset($migrations[$key]);
+ }
return $migrations;
}