diff options
Diffstat (limited to 'phpBB/phpbb')
-rw-r--r-- | phpBB/phpbb/console/command/db/migration_command.php | 2 | ||||
-rw-r--r-- | phpBB/phpbb/db/migration/data/v320/default_data_type_ids.php | 5 | ||||
-rw-r--r-- | phpBB/phpbb/db/migration/schema_generator.php | 9 | ||||
-rw-r--r-- | phpBB/phpbb/db/migrator.php | 41 | ||||
-rw-r--r-- | phpBB/phpbb/extension/base.php | 22 | ||||
-rw-r--r-- | phpBB/phpbb/install/controller/archive_download.php | 6 | ||||
-rw-r--r-- | phpBB/phpbb/install/module/update_database/task/update.php | 2 | ||||
-rw-r--r-- | phpBB/phpbb/language/language.php | 26 |
8 files changed, 84 insertions, 29 deletions
diff --git a/phpBB/phpbb/console/command/db/migration_command.php b/phpBB/phpbb/console/command/db/migration_command.php index d44ef8c5cb..b951560588 100644 --- a/phpBB/phpbb/console/command/db/migration_command.php +++ b/phpBB/phpbb/console/command/db/migration_command.php @@ -45,7 +45,7 @@ abstract class migration_command extends \phpbb\console\command\command $this->migrator->set_migrations($migrations); - return $migrations; + return $this->migrator->get_migrations(); } protected function finalise_update() diff --git a/phpBB/phpbb/db/migration/data/v320/default_data_type_ids.php b/phpBB/phpbb/db/migration/data/v320/default_data_type_ids.php index ecee09ce77..65e5b3fa73 100644 --- a/phpBB/phpbb/db/migration/data/v320/default_data_type_ids.php +++ b/phpBB/phpbb/db/migration/data/v320/default_data_type_ids.php @@ -17,7 +17,10 @@ class default_data_type_ids extends \phpbb\db\migration\migration { static public function depends_on() { - return array('\phpbb\db\migration\data\v320\v320a2'); + return array( + '\phpbb\db\migration\data\v320\v320a2', + '\phpbb\db\migration\data\v320\oauth_states', + ); } public function update_schema() diff --git a/phpBB/phpbb/db/migration/schema_generator.php b/phpBB/phpbb/db/migration/schema_generator.php index 7003844bc4..c579e25824 100644 --- a/phpBB/phpbb/db/migration/schema_generator.php +++ b/phpBB/phpbb/db/migration/schema_generator.php @@ -77,8 +77,15 @@ class schema_generator $check_dependencies = true; while (!empty($migrations)) { - foreach ($migrations as $migration_class) + foreach ($migrations as $key => $migration_class) { + // Unset classes that are not a valid migration + if (\phpbb\db\migrator::is_migration($migration_class) === false) + { + unset($migrations[$key]); + continue; + } + $open_dependencies = array_diff($migration_class::depends_on(), $tree); if (empty($open_dependencies)) diff --git a/phpBB/phpbb/db/migrator.php b/phpBB/phpbb/db/migrator.php index d91860949a..a1e93942cd 100644 --- a/phpBB/phpbb/db/migrator.php +++ b/phpBB/phpbb/db/migrator.php @@ -170,10 +170,28 @@ class migrator */ public function set_migrations($class_names) { + foreach ($class_names as $key => $class) + { + if (!self::is_migration($class)) + { + unset($class_names[$key]); + } + } + $this->migrations = $class_names; } /** + * Get the list of available migration class names + * + * @return array Array of all migrations available to be run + */ + public function get_migrations() + { + return $this->migrations; + } + + /** * Runs a single update step from the next migration to be applied. * * The update step can either be a schema or a (partial) data update. To @@ -857,4 +875,27 @@ class migrator )); } } + + /** + * Check if a class is a migration. + * + * @param string $migration A migration class name + * @return bool Return true if class is a migration, false otherwise + */ + static public function is_migration($migration) + { + if (class_exists($migration)) + { + // Migration classes should extend the abstract class + // 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()) + { + return true; + } + } + + return false; + } } diff --git a/phpBB/phpbb/extension/base.php b/phpBB/phpbb/extension/base.php index b647242b98..c7778cfed1 100644 --- a/phpBB/phpbb/extension/base.php +++ b/phpBB/phpbb/extension/base.php @@ -73,9 +73,7 @@ class base implements \phpbb\extension\extension_interface */ public function enable_step($old_state) { - $migrations = $this->get_migration_file_list(); - - $this->migrator->set_migrations($migrations); + $this->get_migration_file_list(); $this->migrator->update(); @@ -103,8 +101,6 @@ class base implements \phpbb\extension\extension_interface { $migrations = $this->get_migration_file_list(); - $this->migrator->set_migrations($migrations); - foreach ($migrations as $migration) { while ($this->migrator->migration_state($migration) !== false) @@ -137,21 +133,9 @@ 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 - foreach ($migrations as $key => $migration) - { - if (class_exists($migration)) - { - $reflector = new \ReflectionClass($migration); - if ($reflector->implementsInterface('\phpbb\db\migration\migration_interface') && $reflector->isInstantiable()) - { - continue; - } - } + $this->migrator->set_migrations($migrations); - unset($migrations[$key]); - } + $migrations = $this->migrator->get_migrations(); return $migrations; } diff --git a/phpBB/phpbb/install/controller/archive_download.php b/phpBB/phpbb/install/controller/archive_download.php index a0f0ba181d..eabc0a9976 100644 --- a/phpBB/phpbb/install/controller/archive_download.php +++ b/phpBB/phpbb/install/controller/archive_download.php @@ -46,9 +46,9 @@ class archive_download */ public function conflict_archive() { - $filename = $this->installer_config->get('update_file_conflict_archive', false); + $filename = $this->installer_config->get('update_file_conflict_archive', ''); - if (!$filename) + if (empty($filename)) { throw new http_exception(404, 'URL_NOT_FOUND'); } @@ -65,7 +65,7 @@ class archive_download { $filename = $this->installer_config->get('update_file_archive', ''); - if (!$filename) + if (empty($filename)) { throw new http_exception(404, 'URL_NOT_FOUND'); } diff --git a/phpBB/phpbb/install/module/update_database/task/update.php b/phpBB/phpbb/install/module/update_database/task/update.php index 84ec6f73f5..4b2baf2c23 100644 --- a/phpBB/phpbb/install/module/update_database/task/update.php +++ b/phpBB/phpbb/install/module/update_database/task/update.php @@ -140,7 +140,7 @@ class update extends task_base ->get_classes(); $this->migrator->set_migrations($migrations); - $migration_count = count($migrations); + $migration_count = count($this->migrator->get_migrations()); $this->iohandler->set_task_count($migration_count, true); $progress_count = $this->installer_config->get('database_update_count', 0); diff --git a/phpBB/phpbb/language/language.php b/phpBB/phpbb/language/language.php index 382d4db89e..42429c2c07 100644 --- a/phpBB/phpbb/language/language.php +++ b/phpBB/phpbb/language/language.php @@ -246,14 +246,14 @@ class language } /** - * Act like lang() but takes a key and an array of parameters instead of using variadic + * Returns the raw value associated to a language key or the language key no translation is available. + * No parameter substitution is performed, can be a string or an array. * * @param string|array $key Language key - * @param array $args Parameters * * @return array|string */ - public function lang_array($key, $args = array()) + public function lang_raw($key) { // Load common language files if they not loaded yet if (!$this->common_language_files_loaded) @@ -281,6 +281,26 @@ class language return $key; } + return $lang; + } + + /** + * Act like lang() but takes a key and an array of parameters instead of using variadic + * + * @param string|array $key Language key + * @param array $args Parameters + * + * @return string + */ + public function lang_array($key, $args = array()) + { + $lang = $this->lang_raw($key); + + if ($lang === $key) + { + return $key; + } + // If the language entry is a string, we simply mimic sprintf() behaviour if (is_string($lang)) { |