diff --git a/phpBB/phpbb/db/doctrine/table_helper.php b/phpBB/phpbb/db/doctrine/table_helper.php index 98d33b80cd..448597df3d 100644 --- a/phpBB/phpbb/db/doctrine/table_helper.php +++ b/phpBB/phpbb/db/doctrine/table_helper.php @@ -130,11 +130,12 @@ class table_helper * @param array $table_prefix Tables prefix. * * @return array Pairs of table names and their short name representations. + * @psalm-return array{string, string} */ public static function map_short_table_names(array $additional_tables = [], string $table_prefix = ''): array { $short_table_names_map = [ - "{$table_prefix}acl_groups" => 'aclgrps', + "{$table_prefix}acl_groups" => 'aclgrps', "{$table_prefix}acl_options" => 'aclopts', "{$table_prefix}acl_roles" => 'aclrls', "{$table_prefix}acl_roles_data" => 'aclrlsdt', diff --git a/phpBB/phpbb/db/migration/data/v400/rename_duplicated_index_names.php b/phpBB/phpbb/db/migration/data/v400/rename_duplicated_index_names.php index 60900f67ae..e3924c1c9d 100644 --- a/phpBB/phpbb/db/migration/data/v400/rename_duplicated_index_names.php +++ b/phpBB/phpbb/db/migration/data/v400/rename_duplicated_index_names.php @@ -28,12 +28,11 @@ class rename_duplicated_index_names extends migration public function update_schema() { $rename_index = $table_keys = []; - $db_table_schema = json_decode(file_get_contents($this->phpbb_root_path . 'store/schema.json'), true); + $db_table_schema = $this->get_schema(); foreach ($db_table_schema as $table_name => $table_data) { if (isset($table_data['KEYS'])) { - $table_name = $this->table_prefix . $table_name; foreach ($table_data['KEYS'] as $key_name => $key_data) { $table_keys[$table_name][] = $key_name; @@ -66,4 +65,27 @@ class rename_duplicated_index_names extends migration return $schema; } + + protected function get_schema() + { + $self_classname = '\\' . str_replace('/', '\\', self::class); + $finder_factory = new \phpbb\finder\factory(null, false, $this->phpbb_root_path, $this->php_ext); + $finder = $finder_factory->get(); + $migrator_classes = $finder->core_path('phpbb/db/migration/data/')->get_classes(); + $self_class_index = array_search($self_classname, $migrator_classes); + unset($migrator_classes[$self_class_index]); + + $schema_generator = new \phpbb\db\migration\schema_generator( + $migrator_classes, + $this->config, + $this->db, + $this->db_tools, + $this->phpbb_root_path, + $this->php_ext, + $this->table_prefix, + $this->tables + ); + + return $schema_generator->get_schema(); + } }