aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc Alexander <admin@m-a-styles.de>2020-01-14 21:20:09 +0100
committerGitHub <noreply@github.com>2020-01-14 21:20:09 +0100
commita6cd4df423ef7ad8f356dfecf11b26f739c2344f (patch)
tree9254d02abaaccde38b7538bf7d7f5ef013568623
parentMerge branch '3.3.x' (diff)
parent[ticket/16284] Add depends_on to classes (diff)
downloadphpbb-a6cd4df423ef7ad8f356dfecf11b26f739c2344f.tar.gz
phpbb-a6cd4df423ef7ad8f356dfecf11b26f739c2344f.tar.bz2
phpbb-a6cd4df423ef7ad8f356dfecf11b26f739c2344f.zip
Merge pull request #5808 from marc1706/ticket/16284
[ticket/16284] Move 4.0 migrations to v400 folder
-rw-r--r--phpBB/config/default/container/services_migrator.yml1
-rw-r--r--phpBB/config/installer/container/services_install_database.yml1
-rw-r--r--phpBB/develop/create_schema_files.php10
-rw-r--r--phpBB/phpbb/db/migration/data/v330/acp_storage_module.php33
-rw-r--r--phpBB/phpbb/db/migration/data/v330/add_storage_permission.php28
-rw-r--r--phpBB/phpbb/db/migration/data/v330/extensions_composer.php39
-rw-r--r--phpBB/phpbb/db/migration/data/v330/remove_attachment_download_mode.php39
-rw-r--r--phpBB/phpbb/db/migration/data/v330/storage_adapter_local_subfolders.php44
-rw-r--r--phpBB/phpbb/db/migration/data/v330/storage_attachment.php26
-rw-r--r--phpBB/phpbb/db/migration/data/v330/storage_avatar.php26
-rw-r--r--phpBB/phpbb/db/migration/data/v330/storage_backup.php40
-rw-r--r--phpBB/phpbb/db/migration/data/v400/acp_storage_module.php55
-rw-r--r--phpBB/phpbb/db/migration/data/v400/add_storage_permission.php49
-rw-r--r--phpBB/phpbb/db/migration/data/v400/dev.php36
-rw-r--r--phpBB/phpbb/db/migration/data/v400/extensions_composer.php53
-rw-r--r--phpBB/phpbb/db/migration/data/v400/extensions_composer_2.php (renamed from phpBB/phpbb/db/migration/data/v330/extensions_composer_2.php)19
-rw-r--r--phpBB/phpbb/db/migration/data/v400/remove_attachment_download_mode.php53
-rw-r--r--phpBB/phpbb/db/migration/data/v400/storage_adapter_local_subfolders.php54
-rw-r--r--phpBB/phpbb/db/migration/data/v400/storage_attachment.php41
-rw-r--r--phpBB/phpbb/db/migration/data/v400/storage_avatar.php41
-rw-r--r--phpBB/phpbb/db/migration/data/v400/storage_backup.php55
-rw-r--r--phpBB/phpbb/db/migration/data/v400/storage_track.php (renamed from phpBB/phpbb/db/migration/data/v330/storage_track.php)69
-rw-r--r--phpBB/phpbb/db/migration/migration.php7
-rw-r--r--phpBB/phpbb/db/migration/schema_generator.php20
-rw-r--r--phpBB/phpbb/db/migrator.php35
-rw-r--r--phpBB/phpbb/install/module/install_database/task/create_schema.php54
-rw-r--r--phpBB/phpbb/install/module/install_database/task/create_schema_file.php10
-rw-r--r--tests/dbal/migrator_test.php1
-rw-r--r--tests/extension/manager_test.php1
-rw-r--r--tests/extension/metadata_manager_test.php1
-rw-r--r--tests/migrator/convert_timezones_test.php3
-rw-r--r--tests/migrator/get_callable_from_step_test.php1
-rw-r--r--tests/migrator/schema_generator_test.php2
-rw-r--r--tests/notification/convert_test.php3
-rw-r--r--tests/test_framework/phpbb_database_test_case.php22
-rw-r--r--tests/test_framework/phpbb_database_test_connection_manager.php3
-rw-r--r--tests/test_framework/phpbb_functional_test_case.php1
-rw-r--r--tests/test_framework/phpbb_ui_test_case.php1
38 files changed, 625 insertions, 352 deletions
diff --git a/phpBB/config/default/container/services_migrator.yml b/phpBB/config/default/container/services_migrator.yml
index c63b087adb..3362598204 100644
--- a/phpBB/config/default/container/services_migrator.yml
+++ b/phpBB/config/default/container/services_migrator.yml
@@ -11,6 +11,7 @@ services:
- '%core.root_path%'
- '%core.php_ext%'
- '%core.table_prefix%'
+ - '%tables%'
- '@migrator.tool_collection'
- '@migrator.helper'
diff --git a/phpBB/config/installer/container/services_install_database.yml b/phpBB/config/installer/container/services_install_database.yml
index 33f596506d..bc35c6af4e 100644
--- a/phpBB/config/installer/container/services_install_database.yml
+++ b/phpBB/config/installer/container/services_install_database.yml
@@ -7,6 +7,7 @@ services:
- '@filesystem'
- '%core.root_path%'
- '%core.php_ext%'
+ - '%tables%'
tags:
- { name: install_database_install, order: 10 }
diff --git a/phpBB/develop/create_schema_files.php b/phpBB/develop/create_schema_files.php
index fe2b2154a5..311b2fc94a 100644
--- a/phpBB/develop/create_schema_files.php
+++ b/phpBB/develop/create_schema_files.php
@@ -52,7 +52,15 @@ $db = new \phpbb\db\driver\sqlite3();
$factory = new \phpbb\db\tools\factory();
$db_tools = $factory->get($db, true);
-$schema_generator = new \phpbb\db\migration\schema_generator($classes, new \phpbb\config\config(array()), $db, $db_tools, $phpbb_root_path, $phpEx, $table_prefix);
+$tables_data = \Symfony\Component\Yaml\Yaml::parseFile($phpbb_root_path . '/config/default/container/tables.yml');
+$tables = [];
+
+foreach ($tables_data['parameters'] as $parameter => $table)
+{
+ $tables[str_replace('tables.', '', $parameter)] = str_replace('%core.table_prefix%', $table_prefix, $table);
+}
+
+$schema_generator = new \phpbb\db\migration\schema_generator($classes, new \phpbb\config\config(array()), $db, $db_tools, $phpbb_root_path, $phpEx, $table_prefix, $tables);
$schema_data = $schema_generator->get_schema();
$fp = fopen($schema_path . 'schema.json', 'wb');
diff --git a/phpBB/phpbb/db/migration/data/v330/acp_storage_module.php b/phpBB/phpbb/db/migration/data/v330/acp_storage_module.php
deleted file mode 100644
index d5491a625e..0000000000
--- a/phpBB/phpbb/db/migration/data/v330/acp_storage_module.php
+++ /dev/null
@@ -1,33 +0,0 @@
-<?php
-/**
-*
-* This file is part of the phpBB Forum Software package.
-*
-* @copyright (c) phpBB Limited <https://www.phpbb.com>
-* @license GNU General Public License, version 2 (GPL-2.0)
-*
-* For full copyright and license information, please see
-* the docs/CREDITS.txt file.
-*
-*/
-
-namespace phpbb\db\migration\data\v330;
-
-class acp_storage_module extends \phpbb\db\migration\migration
-{
- public function update_data()
- {
- return array(
- array('module.add', array(
- 'acp',
- 'ACP_SERVER_CONFIGURATION',
- array(
- 'module_basename' => 'acp_storage',
- 'module_langname' => 'ACP_STORAGE_SETTINGS',
- 'module_mode' => 'settings',
- 'module_auth' => 'acl_a_storage',
- ),
- )),
- );
- }
-}
diff --git a/phpBB/phpbb/db/migration/data/v330/add_storage_permission.php b/phpBB/phpbb/db/migration/data/v330/add_storage_permission.php
deleted file mode 100644
index 0836462f03..0000000000
--- a/phpBB/phpbb/db/migration/data/v330/add_storage_permission.php
+++ /dev/null
@@ -1,28 +0,0 @@
-<?php
-/**
-*
-* This file is part of the phpBB Forum Software package.
-*
-* @copyright (c) phpBB Limited <https://www.phpbb.com>
-* @license GNU General Public License, version 2 (GPL-2.0)
-*
-* For full copyright and license information, please see
-* the docs/CREDITS.txt file.
-*
-*/
-
-namespace phpbb\db\migration\data\v330;
-
-class add_storage_permission extends \phpbb\db\migration\migration
-{
- public function update_data()
- {
- return array(
- // Add permission
- array('permission.add', array('a_storage')),
-
- // Set permissions
- array('permission.permission_set', array('ROLE_ADMIN_FULL', 'a_storage')),
- );
- }
-}
diff --git a/phpBB/phpbb/db/migration/data/v330/extensions_composer.php b/phpBB/phpbb/db/migration/data/v330/extensions_composer.php
deleted file mode 100644
index 7e12150e56..0000000000
--- a/phpBB/phpbb/db/migration/data/v330/extensions_composer.php
+++ /dev/null
@@ -1,39 +0,0 @@
-<?php
-/**
-*
-* This file is part of the phpBB Forum Software package.
-*
-* @copyright (c) phpBB Limited <https://www.phpbb.com>
-* @license GNU General Public License, version 2 (GPL-2.0)
-*
-* For full copyright and license information, please see
-* the docs/CREDITS.txt file.
-*
-*/
-
-namespace phpbb\db\migration\data\v330;
-
-class extensions_composer extends \phpbb\db\migration\migration
-{
- public function update_data()
- {
- return array(
- array('config.add', array('exts_composer_repositories', json_encode([
- 'https://www.phpbb.com/customise/db/composer/',
- ], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES))),
- array('config.add', array('exts_composer_packagist', false)),
- array('config.add', array('exts_composer_json_file', 'composer-ext.json')),
- array('config.add', array('exts_composer_vendor_dir', 'vendor-ext/')),
- array('config.add', array('exts_composer_enable_on_install', false)),
- array('config.add', array('exts_composer_purge_on_remove', true)),
- array('module.add', array(
- 'acp',
- 'ACP_EXTENSION_MANAGEMENT',
- array(
- 'module_basename' => 'acp_extensions',
- 'modes' => array('catalog'),
- ),
- )),
- );
- }
-}
diff --git a/phpBB/phpbb/db/migration/data/v330/remove_attachment_download_mode.php b/phpBB/phpbb/db/migration/data/v330/remove_attachment_download_mode.php
deleted file mode 100644
index 988a7167b1..0000000000
--- a/phpBB/phpbb/db/migration/data/v330/remove_attachment_download_mode.php
+++ /dev/null
@@ -1,39 +0,0 @@
-<?php
-/**
-*
-* This file is part of the phpBB Forum Software package.
-*
-* @copyright (c) phpBB Limited <https://www.phpbb.com>
-* @license GNU General Public License, version 2 (GPL-2.0)
-*
-* For full copyright and license information, please see
-* the docs/CREDITS.txt file.
-*
-*/
-
-namespace phpbb\db\migration\data\v330;
-
-class remove_attachment_download_mode extends \phpbb\db\migration\migration
-{
- public function update_schema()
- {
- return array(
- 'drop_columns' => array(
- $this->table_prefix . 'extension_groups' => array(
- 'download_mode',
- ),
- ),
- );
- }
-
- public function revert_schema()
- {
- return array(
- 'add_columns' => array(
- $this->table_prefix . 'extension_groups' => array(
- 'download_mode' => array('BOOL', '1'),
- ),
- ),
- );
- }
-}
diff --git a/phpBB/phpbb/db/migration/data/v330/storage_adapter_local_subfolders.php b/phpBB/phpbb/db/migration/data/v330/storage_adapter_local_subfolders.php
deleted file mode 100644
index 491388054c..0000000000
--- a/phpBB/phpbb/db/migration/data/v330/storage_adapter_local_subfolders.php
+++ /dev/null
@@ -1,44 +0,0 @@
-<?php
-/**
-*
-* This file is part of the phpBB Forum Software package.
-*
-* @copyright (c) phpBB Limited <https://www.phpbb.com>
-* @license GNU General Public License, version 2 (GPL-2.0)
-*
-* For full copyright and license information, please see
-* the docs/CREDITS.txt file.
-*
-*/
-
-namespace phpbb\db\migration\data\v330;
-
-class storage_adapter_local_subfolders extends \phpbb\db\migration\migration
-{
- static public function depends_on()
- {
- return array(
- '\phpbb\db\migration\data\v330\storage_attachment',
- '\phpbb\db\migration\data\v330\storage_avatar',
- '\phpbb\db\migration\data\v330\storage_backup',
- );
- }
-
- public function update_data()
- {
- return array(
- array('if', array(
- ($this->config['storage\\attachment\\provider'] == \phpbb\storage\provider\local::class),
- array('config.add', array('storage\\attachment\\config\\subfolders', '0')),
- )),
- array('if', array(
- ($this->config['storage\\avatar\\provider'] == \phpbb\storage\provider\local::class),
- array('config.add', array('storage\\avatar\\config\\subfolders', '0')),
- )),
- array('if', array(
- ($this->config['storage\\backup\\provider'] == \phpbb\storage\provider\local::class),
- array('config.add', array('storage\\backup\\config\\subfolders', '0')),
- )),
- );
- }
-}
diff --git a/phpBB/phpbb/db/migration/data/v330/storage_attachment.php b/phpBB/phpbb/db/migration/data/v330/storage_attachment.php
deleted file mode 100644
index 626bafed65..0000000000
--- a/phpBB/phpbb/db/migration/data/v330/storage_attachment.php
+++ /dev/null
@@ -1,26 +0,0 @@
-<?php
-/**
-*
-* This file is part of the phpBB Forum Software package.
-*
-* @copyright (c) phpBB Limited <https://www.phpbb.com>
-* @license GNU General Public License, version 2 (GPL-2.0)
-*
-* For full copyright and license information, please see
-* the docs/CREDITS.txt file.
-*
-*/
-
-namespace phpbb\db\migration\data\v330;
-
-class storage_attachment extends \phpbb\db\migration\migration
-{
- public function update_data()
- {
- return array(
- array('config.add', array('storage\\attachment\\provider', \phpbb\storage\provider\local::class)),
- array('config.add', array('storage\\attachment\\config\\path', $this->config['upload_path'])),
- array('config.remove', array('upload_path')),
- );
- }
-}
diff --git a/phpBB/phpbb/db/migration/data/v330/storage_avatar.php b/phpBB/phpbb/db/migration/data/v330/storage_avatar.php
deleted file mode 100644
index 077904daa6..0000000000
--- a/phpBB/phpbb/db/migration/data/v330/storage_avatar.php
+++ /dev/null
@@ -1,26 +0,0 @@
-<?php
-/**
-*
-* This file is part of the phpBB Forum Software package.
-*
-* @copyright (c) phpBB Limited <https://www.phpbb.com>
-* @license GNU General Public License, version 2 (GPL-2.0)
-*
-* For full copyright and license information, please see
-* the docs/CREDITS.txt file.
-*
-*/
-
-namespace phpbb\db\migration\data\v330;
-
-class storage_avatar extends \phpbb\db\migration\migration
-{
- public function update_data()
- {
- return array(
- array('config.add', array('storage\\avatar\\provider', \phpbb\storage\provider\local::class)),
- array('config.add', array('storage\\avatar\\config\\path', $this->config['avatar_path'])),
- array('config.remove', array('avatar_path')),
- );
- }
-}
diff --git a/phpBB/phpbb/db/migration/data/v330/storage_backup.php b/phpBB/phpbb/db/migration/data/v330/storage_backup.php
deleted file mode 100644
index 316ba4c104..0000000000
--- a/phpBB/phpbb/db/migration/data/v330/storage_backup.php
+++ /dev/null
@@ -1,40 +0,0 @@
-<?php
-/**
-*
-* This file is part of the phpBB Forum Software package.
-*
-* @copyright (c) phpBB Limited <https://www.phpbb.com>
-* @license GNU General Public License, version 2 (GPL-2.0)
-*
-* For full copyright and license information, please see
-* the docs/CREDITS.txt file.
-*
-*/
-
-namespace phpbb\db\migration\data\v330;
-
-class storage_backup extends \phpbb\db\migration\migration
-{
- public function update_schema()
- {
- return array(
- 'add_tables' => array(
- $this->table_prefix . 'backups' => array(
- 'COLUMNS' => array(
- 'backup_id' => array('UINT', null, 'auto_increment'),
- 'filename' => array('VCHAR', ''),
- ),
- 'PRIMARY_KEY' => 'backup_id',
- ),
- ),
- );
- }
-
- public function update_data()
- {
- return array(
- array('config.add', array('storage\\backup\\provider', \phpbb\storage\provider\local::class)),
- array('config.add', array('storage\\backup\\config\\path', 'store')),
- );
- }
-}
diff --git a/phpBB/phpbb/db/migration/data/v400/acp_storage_module.php b/phpBB/phpbb/db/migration/data/v400/acp_storage_module.php
new file mode 100644
index 0000000000..7177a6a0ee
--- /dev/null
+++ b/phpBB/phpbb/db/migration/data/v400/acp_storage_module.php
@@ -0,0 +1,55 @@
+<?php
+/**
+*
+* This file is part of the phpBB Forum Software package.
+*
+* @copyright (c) phpBB Limited <https://www.phpbb.com>
+* @license GNU General Public License, version 2 (GPL-2.0)
+*
+* For full copyright and license information, please see
+* the docs/CREDITS.txt file.
+*
+*/
+
+namespace phpbb\db\migration\data\v400;
+
+use phpbb\db\migration\migration;
+
+class acp_storage_module extends migration
+{
+ public function effectively_installed()
+ {
+ $sql = 'SELECT module_id
+ FROM ' . $this->tables['modules'] . "
+ WHERE module_class = 'acp'
+ AND module_langname = 'ACP_STORAGE_SETTINGS'";
+ $result = $this->db->sql_query($sql);
+ $acp_storage_module_id = (int) $this->db->sql_fetchfield('module_id');
+ $this->db->sql_freeresult($result);
+
+ return !empty($acp_storage_module_id);
+ }
+
+ static public function depends_on()
+ {
+ return [
+ '\phpbb\db\migration\data\v400\dev',
+ ];
+ }
+
+ public function update_data()
+ {
+ return [
+ ['module.add', [
+ 'acp',
+ 'ACP_SERVER_CONFIGURATION',
+ [
+ 'module_basename' => 'acp_storage',
+ 'module_langname' => 'ACP_STORAGE_SETTINGS',
+ 'module_mode' => 'settings',
+ 'module_auth' => 'acl_a_storage',
+ ],
+ ]],
+ ];
+ }
+}
diff --git a/phpBB/phpbb/db/migration/data/v400/add_storage_permission.php b/phpBB/phpbb/db/migration/data/v400/add_storage_permission.php
new file mode 100644
index 0000000000..de7b1786d8
--- /dev/null
+++ b/phpBB/phpbb/db/migration/data/v400/add_storage_permission.php
@@ -0,0 +1,49 @@
+<?php
+/**
+*
+* This file is part of the phpBB Forum Software package.
+*
+* @copyright (c) phpBB Limited <https://www.phpbb.com>
+* @license GNU General Public License, version 2 (GPL-2.0)
+*
+* For full copyright and license information, please see
+* the docs/CREDITS.txt file.
+*
+*/
+
+namespace phpbb\db\migration\data\v400;
+
+use phpbb\db\migration\migration;
+
+class add_storage_permission extends migration
+{
+ public function effectively_installed()
+ {
+ $sql = 'SELECT auth_option_id
+ FROM ' . $this->tables['acl_options'] . "
+ WHERE auth_option = 'a_storage'";
+ $result = $this->db->sql_query($sql);
+ $a_storage_option_id = (int) $this->db->sql_fetchfield('auth_option_id');
+ $this->db->sql_freeresult($result);
+
+ return !empty($a_storage_option_id);
+ }
+
+ static public function depends_on()
+ {
+ return [
+ '\phpbb\db\migration\data\v400\dev',
+ ];
+ }
+
+ public function update_data()
+ {
+ return [
+ // Add permission
+ ['permission.add', ['a_storage']],
+
+ // Set permissions
+ ['permission.permission_set', ['ROLE_ADMIN_FULL', 'a_storage']],
+ ];
+ }
+}
diff --git a/phpBB/phpbb/db/migration/data/v400/dev.php b/phpBB/phpbb/db/migration/data/v400/dev.php
new file mode 100644
index 0000000000..b47525384a
--- /dev/null
+++ b/phpBB/phpbb/db/migration/data/v400/dev.php
@@ -0,0 +1,36 @@
+<?php
+/**
+*
+* This file is part of the phpBB Forum Software package.
+*
+* @copyright (c) phpBB Limited <https://www.phpbb.com>
+* @license GNU General Public License, version 2 (GPL-2.0)
+*
+* For full copyright and license information, please see
+* the docs/CREDITS.txt file.
+*
+*/
+
+namespace phpbb\db\migration\data\v400;
+
+use phpbb\db\migration\migration;
+
+class dev extends migration
+{
+ public function effectively_installed()
+ {
+ return version_compare($this->config['version'], '4.0.0-dev', '>=');
+ }
+
+ static public function depends_on()
+ {
+ return ['\phpbb\db\migration\data\v330\v330rc1'];
+ }
+
+ public function update_data()
+ {
+ return [
+ ['config.update', ['version', '4.0.0-dev']],
+ ];
+ }
+}
diff --git a/phpBB/phpbb/db/migration/data/v400/extensions_composer.php b/phpBB/phpbb/db/migration/data/v400/extensions_composer.php
new file mode 100644
index 0000000000..fce3847972
--- /dev/null
+++ b/phpBB/phpbb/db/migration/data/v400/extensions_composer.php
@@ -0,0 +1,53 @@
+<?php
+/**
+*
+* This file is part of the phpBB Forum Software package.
+*
+* @copyright (c) phpBB Limited <https://www.phpbb.com>
+* @license GNU General Public License, version 2 (GPL-2.0)
+*
+* For full copyright and license information, please see
+* the docs/CREDITS.txt file.
+*
+*/
+
+namespace phpbb\db\migration\data\v400;
+
+use phpbb\db\migration\migration;
+
+class extensions_composer extends migration
+{
+ public function effectively_installed()
+ {
+ return $this->config->offsetExists('exts_composer_repositories');
+ }
+
+ static public function depends_on()
+ {
+ return [
+ '\phpbb\db\migration\data\v400\dev',
+ ];
+ }
+
+ public function update_data()
+ {
+ return [
+ ['config.add', ['exts_composer_repositories', json_encode([
+ 'https://www.phpbb.com/customise/db/composer/',
+ ], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES)]],
+ ['config.add', ['exts_composer_packagist', false]],
+ ['config.add', ['exts_composer_json_file', 'composer-ext.json']],
+ ['config.add', ['exts_composer_vendor_dir', 'vendor-ext/']],
+ ['config.add', ['exts_composer_enable_on_install', false]],
+ ['config.add', ['exts_composer_purge_on_remove', true]],
+ ['module.add', [
+ 'acp',
+ 'ACP_EXTENSION_MANAGEMENT',
+ [
+ 'module_basename' => 'acp_extensions',
+ 'modes' => ['catalog'],
+ ],
+ ]],
+ ];
+ }
+}
diff --git a/phpBB/phpbb/db/migration/data/v330/extensions_composer_2.php b/phpBB/phpbb/db/migration/data/v400/extensions_composer_2.php
index 8199dc807e..d72e2145e3 100644
--- a/phpBB/phpbb/db/migration/data/v330/extensions_composer_2.php
+++ b/phpBB/phpbb/db/migration/data/v400/extensions_composer_2.php
@@ -11,23 +11,30 @@
*
*/
-namespace phpbb\db\migration\data\v330;
+namespace phpbb\db\migration\data\v400;
-class extensions_composer_2 extends \phpbb\db\migration\migration
+use phpbb\db\migration\migration;
+
+class extensions_composer_2 extends migration
{
+ public function effectively_installed()
+ {
+ return strpos($this->config['exts_composer_repositories'], 'https://satis.phpbb.com') !== false;
+ }
+
public function update_data()
{
$repositories = json_decode($this->config['exts_composer_repositories'], true);
$repositories[] = 'https://satis.phpbb.com';
$repositories = array_unique($repositories);
- return array(
- array('config.update', array('exts_composer_repositories', json_encode($repositories, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES))),
- );
+ return [
+ ['config.update', ['exts_composer_repositories', json_encode($repositories, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES)]],
+ ];
}
static public function depends_on()
{
- return array('\phpbb\db\migration\data\v330\extensions_composer');
+ return ['\phpbb\db\migration\data\v400\extensions_composer'];
}
}
diff --git a/phpBB/phpbb/db/migration/data/v400/remove_attachment_download_mode.php b/phpBB/phpbb/db/migration/data/v400/remove_attachment_download_mode.php
new file mode 100644
index 0000000000..59ac1b7be0
--- /dev/null
+++ b/phpBB/phpbb/db/migration/data/v400/remove_attachment_download_mode.php
@@ -0,0 +1,53 @@
+<?php
+/**
+*
+* This file is part of the phpBB Forum Software package.
+*
+* @copyright (c) phpBB Limited <https://www.phpbb.com>
+* @license GNU General Public License, version 2 (GPL-2.0)
+*
+* For full copyright and license information, please see
+* the docs/CREDITS.txt file.
+*
+*/
+
+namespace phpbb\db\migration\data\v400;
+
+use phpbb\db\migration\migration;
+
+class remove_attachment_download_mode extends migration
+{
+ public function effectively_installed()
+ {
+ return !$this->db_tools->sql_column_exists($this->tables['extension_groups'], 'download_mode');
+ }
+
+ static public function depends_on()
+ {
+ return [
+ '\phpbb\db\migration\data\v400\dev',
+ ];
+ }
+
+ public function update_schema()
+ {
+ return [
+ 'drop_columns' => [
+ $this->table_prefix . 'extension_groups' => [
+ 'download_mode',
+ ],
+ ],
+ ];
+ }
+
+ public function revert_schema()
+ {
+ return [
+ 'add_columns' => [
+ $this->table_prefix . 'extension_groups' => [
+ 'download_mode' => ['BOOL', '1'],
+ ],
+ ],
+ ];
+ }
+}
diff --git a/phpBB/phpbb/db/migration/data/v400/storage_adapter_local_subfolders.php b/phpBB/phpbb/db/migration/data/v400/storage_adapter_local_subfolders.php
new file mode 100644
index 0000000000..3c4e5e3a0f
--- /dev/null
+++ b/phpBB/phpbb/db/migration/data/v400/storage_adapter_local_subfolders.php
@@ -0,0 +1,54 @@
+<?php
+/**
+*
+* This file is part of the phpBB Forum Software package.
+*
+* @copyright (c) phpBB Limited <https://www.phpbb.com>
+* @license GNU General Public License, version 2 (GPL-2.0)
+*
+* For full copyright and license information, please see
+* the docs/CREDITS.txt file.
+*
+*/
+
+namespace phpbb\db\migration\data\v400;
+
+use phpbb\db\migration\migration;
+use phpbb\storage\provider\local;
+
+class storage_adapter_local_subfolders extends migration
+{
+ public function effectively_installed()
+ {
+ return $this->config->offsetExists('storage\\attachment\\config\\subfolders') ||
+ $this->config->offsetExists('storage\\avatar\\config\\subfolders') ||
+ $this->config->offsetExists('storage\\backup\\config\\subfolders');
+ }
+
+ static public function depends_on()
+ {
+ return [
+ '\phpbb\db\migration\data\v400\storage_attachment',
+ '\phpbb\db\migration\data\v400\storage_avatar',
+ '\phpbb\db\migration\data\v400\storage_backup',
+ ];
+ }
+
+ public function update_data()
+ {
+ return [
+ ['if', [
+ ($this->config['storage\\attachment\\provider'] == local::class),
+ ['config.add', ['storage\\attachment\\config\\subfolders', '0']],
+ ]],
+ ['if', [
+ ($this->config['storage\\avatar\\provider'] == local::class),
+ ['config.add', ['storage\\avatar\\config\\subfolders', '0']],
+ ]],
+ ['if', [
+ ($this->config['storage\\backup\\provider'] == local::class),
+ ['config.add', ['storage\\backup\\config\\subfolders', '0']],
+ ]],
+ ];
+ }
+}
diff --git a/phpBB/phpbb/db/migration/data/v400/storage_attachment.php b/phpBB/phpbb/db/migration/data/v400/storage_attachment.php
new file mode 100644
index 0000000000..7d091ac093
--- /dev/null
+++ b/phpBB/phpbb/db/migration/data/v400/storage_attachment.php
@@ -0,0 +1,41 @@
+<?php
+/**
+*
+* This file is part of the phpBB Forum Software package.
+*
+* @copyright (c) phpBB Limited <https://www.phpbb.com>
+* @license GNU General Public License, version 2 (GPL-2.0)
+*
+* For full copyright and license information, please see
+* the docs/CREDITS.txt file.
+*
+*/
+
+namespace phpbb\db\migration\data\v400;
+
+use phpbb\db\migration\migration;
+use phpbb\storage\provider\local;
+
+class storage_attachment extends migration
+{
+ public function effectively_installed()
+ {
+ return $this->config->offsetExists('storage\\attachment\\provider');
+ }
+
+ static public function depends_on()
+ {
+ return [
+ '\phpbb\db\migration\data\v400\dev',
+ ];
+ }
+
+ public function update_data()
+ {
+ return [
+ ['config.add', ['storage\\attachment\\provider', local::class]],
+ ['config.add', ['storage\\attachment\\config\\path', $this->config['upload_path']]],
+ ['config.remove', ['upload_path']],
+ ];
+ }
+}
diff --git a/phpBB/phpbb/db/migration/data/v400/storage_avatar.php b/phpBB/phpbb/db/migration/data/v400/storage_avatar.php
new file mode 100644
index 0000000000..cbb93b4775
--- /dev/null
+++ b/phpBB/phpbb/db/migration/data/v400/storage_avatar.php
@@ -0,0 +1,41 @@
+<?php
+/**
+*
+* This file is part of the phpBB Forum Software package.
+*
+* @copyright (c) phpBB Limited <https://www.phpbb.com>
+* @license GNU General Public License, version 2 (GPL-2.0)
+*
+* For full copyright and license information, please see
+* the docs/CREDITS.txt file.
+*
+*/
+
+namespace phpbb\db\migration\data\v400;
+
+use phpbb\db\migration\migration;
+use phpbb\storage\provider\local;
+
+class storage_avatar extends migration
+{
+ public function effectively_installed()
+ {
+ return $this->config->offsetExists('storage\\avatar\\provider');
+ }
+
+ static public function depends_on()
+ {
+ return [
+ '\phpbb\db\migration\data\v400\dev',
+ ];
+ }
+
+ public function update_data()
+ {
+ return [
+ ['config.add', ['storage\\avatar\\provider', local::class]],
+ ['config.add', ['storage\\avatar\\config\\path', $this->config['avatar_path']]],
+ ['config.remove', ['avatar_path']],
+ ];
+ }
+}
diff --git a/phpBB/phpbb/db/migration/data/v400/storage_backup.php b/phpBB/phpbb/db/migration/data/v400/storage_backup.php
new file mode 100644
index 0000000000..3677620508
--- /dev/null
+++ b/phpBB/phpbb/db/migration/data/v400/storage_backup.php
@@ -0,0 +1,55 @@
+<?php
+/**
+*
+* This file is part of the phpBB Forum Software package.
+*
+* @copyright (c) phpBB Limited <https://www.phpbb.com>
+* @license GNU General Public License, version 2 (GPL-2.0)
+*
+* For full copyright and license information, please see
+* the docs/CREDITS.txt file.
+*
+*/
+
+namespace phpbb\db\migration\data\v400;
+
+use phpbb\db\migration\migration;
+use phpbb\storage\provider\local;
+
+class storage_backup extends migration
+{
+ public function effectively_installed()
+ {
+ return $this->db_tools->sql_table_exists($this->tables['backups']);
+ }
+
+ static public function depends_on()
+ {
+ return [
+ '\phpbb\db\migration\data\v400\dev',
+ ];
+ }
+
+ public function update_schema()
+ {
+ return [
+ 'add_tables' => [
+ $this->table_prefix . 'backups' => [
+ 'COLUMNS' => [
+ 'backup_id' => ['UINT', null, 'auto_increment'],
+ 'filename' => ['VCHAR', ''],
+ ],
+ 'PRIMARY_KEY' => 'backup_id',
+ ],
+ ],
+ ];
+ }
+
+ public function update_data()
+ {
+ return [
+ ['config.add', ['storage\\backup\\provider', local::class]],
+ ['config.add', ['storage\\backup\\config\\path', 'store']],
+ ];
+ }
+}
diff --git a/phpBB/phpbb/db/migration/data/v330/storage_track.php b/phpBB/phpbb/db/migration/data/v400/storage_track.php
index 5abd875ae9..a4aec87fb2 100644
--- a/phpBB/phpbb/db/migration/data/v330/storage_track.php
+++ b/phpBB/phpbb/db/migration/data/v400/storage_track.php
@@ -11,45 +11,52 @@
*
*/
-namespace phpbb\db\migration\data\v330;
+namespace phpbb\db\migration\data\v400;
+use phpbb\db\migration\container_aware_migration;
+use phpbb\storage\exception\exception;
use phpbb\storage\storage;
-class storage_track extends \phpbb\db\migration\container_aware_migration
+class storage_track extends container_aware_migration
{
+ public function effectively_installed()
+ {
+ return $this->db_tools->sql_table_exists($this->tables['storage']);
+ }
+
static public function depends_on()
{
- return array(
- '\phpbb\db\migration\data\v330\storage_attachment',
- '\phpbb\db\migration\data\v330\storage_avatar',
- '\phpbb\db\migration\data\v330\storage_backup',
- );
+ return [
+ '\phpbb\db\migration\data\v400\storage_attachment',
+ '\phpbb\db\migration\data\v400\storage_avatar',
+ '\phpbb\db\migration\data\v400\storage_backup',
+ ];
}
public function update_schema()
{
- return array(
- 'add_tables' => array(
- $this->table_prefix . 'storage' => array(
- 'COLUMNS' => array(
- 'file_id' => array('UINT', null, 'auto_increment'),
- 'file_path' => array('VCHAR', ''),
- 'storage' => array('VCHAR', ''),
- 'filesize' => array('UINT:20', 0),
- ),
+ return [
+ 'add_tables' => [
+ $this->table_prefix . 'storage' => [
+ 'COLUMNS' => [
+ 'file_id' => ['UINT', null, 'auto_increment'],
+ 'file_path' => ['VCHAR', ''],
+ 'storage' => ['VCHAR', ''],
+ 'filesize' => ['UINT:20', 0],
+ ],
'PRIMARY_KEY' => 'file_id',
- ),
- ),
- );
+ ],
+ ],
+ ];
}
public function revert_schema()
{
- return array(
- 'drop_tables' => array(
+ return [
+ 'drop_tables' => [
$this->table_prefix . 'storage',
- ),
- );
+ ],
+ ];
}
public function update_data()
@@ -90,9 +97,9 @@ class storage_track extends \phpbb\db\migration\container_aware_migration
{
$storage->track_file($this->config['avatar_salt'] . '_' . ($avatar_group ? 'g' : '') . $filename . '.' . $ext);
}
- catch (\phpbb\storage\exception\exception $e)
+ catch (exception $e)
{
- // If file don't exist, don't track it
+ // If file doesn't exist, don't track it
}
}
$this->db->sql_freeresult($result);
@@ -114,9 +121,9 @@ class storage_track extends \phpbb\db\migration\container_aware_migration
{
$storage->track_file($row['physical_filename']);
}
- catch (\phpbb\storage\exception\exception $e)
+ catch (exception $e)
{
- // If file don't exist, don't track it
+ // If file doesn't exist, don't track it
}
if ($row['thumbnail'] == 1)
@@ -125,9 +132,9 @@ class storage_track extends \phpbb\db\migration\container_aware_migration
{
$storage->track_file('thumb_' . $row['physical_filename']);
}
- catch (\phpbb\storage\exception\exception $e)
+ catch (exception $e)
{
- // If file don't exist, don't track it
+ // If file doesn't exist, don't track it
}
}
}
@@ -150,9 +157,9 @@ class storage_track extends \phpbb\db\migration\container_aware_migration
{
$storage->track_file($row['filename']);
}
- catch (\phpbb\storage\exception\exception $e)
+ catch (exception $e)
{
- // If file don't exist, don't track it
+ // If file doesn't exist, don't track it
}
}
diff --git a/phpBB/phpbb/db/migration/migration.php b/phpBB/phpbb/db/migration/migration.php
index 4e218344f4..c94ac29407 100644
--- a/phpBB/phpbb/db/migration/migration.php
+++ b/phpBB/phpbb/db/migration/migration.php
@@ -34,6 +34,9 @@ abstract class migration implements migration_interface
/** @var string */
protected $table_prefix;
+ /** @var array Tables array */
+ protected $tables;
+
/** @var string */
protected $phpbb_root_path;
@@ -55,13 +58,15 @@ abstract class migration implements migration_interface
* @param string $phpbb_root_path
* @param string $php_ext
* @param string $table_prefix
+ * @param array $tables
*/
- public function __construct(\phpbb\config\config $config, \phpbb\db\driver\driver_interface $db, \phpbb\db\tools\tools_interface $db_tools, $phpbb_root_path, $php_ext, $table_prefix)
+ public function __construct(\phpbb\config\config $config, \phpbb\db\driver\driver_interface $db, \phpbb\db\tools\tools_interface $db_tools, $phpbb_root_path, $php_ext, $table_prefix, $tables)
{
$this->config = $config;
$this->db = $db;
$this->db_tools = $db_tools;
$this->table_prefix = $table_prefix;
+ $this->tables = $tables;
$this->phpbb_root_path = $phpbb_root_path;
$this->php_ext = $php_ext;
diff --git a/phpBB/phpbb/db/migration/schema_generator.php b/phpBB/phpbb/db/migration/schema_generator.php
index c579e25824..0d1f6e33b1 100644
--- a/phpBB/phpbb/db/migration/schema_generator.php
+++ b/phpBB/phpbb/db/migration/schema_generator.php
@@ -43,12 +43,23 @@ class schema_generator
protected $tables;
/** @var array */
+ protected $table_names;
+
+ /** @var array */
protected $dependencies = array();
/**
- * Constructor
- */
- public function __construct(array $class_names, \phpbb\config\config $config, \phpbb\db\driver\driver_interface $db, \phpbb\db\tools\tools_interface $db_tools, $phpbb_root_path, $php_ext, $table_prefix)
+ * Constructor
+ * @param array $class_names
+ * @param \phpbb\config\config $config
+ * @param \phpbb\db\driver\driver_interface $db
+ * @param \phpbb\db\tools\tools_interface $db_tools
+ * @param string $phpbb_root_path
+ * @param string $php_ext
+ * @param string $table_prefix
+ * @param array $tables
+ */
+ public function __construct(array $class_names, \phpbb\config\config $config, \phpbb\db\driver\driver_interface $db, \phpbb\db\tools\tools_interface $db_tools, $phpbb_root_path, $php_ext, $table_prefix, $tables)
{
$this->config = $config;
$this->db = $db;
@@ -57,6 +68,7 @@ class schema_generator
$this->phpbb_root_path = $phpbb_root_path;
$this->php_ext = $php_ext;
$this->table_prefix = $table_prefix;
+ $this->table_names = $tables;
}
/**
@@ -90,7 +102,7 @@ class schema_generator
if (empty($open_dependencies))
{
- $migration = new $migration_class($this->config, $this->db, $this->db_tools, $this->phpbb_root_path, $this->php_ext, $this->table_prefix);
+ $migration = new $migration_class($this->config, $this->db, $this->db_tools, $this->phpbb_root_path, $this->php_ext, $this->table_prefix, $this->table_names);
$tree[] = $migration_class;
$migration_key = array_search($migration_class, $migrations);
diff --git a/phpBB/phpbb/db/migrator.php b/phpBB/phpbb/db/migrator.php
index 3a1ee758cf..e93b96ad28 100644
--- a/phpBB/phpbb/db/migrator.php
+++ b/phpBB/phpbb/db/migrator.php
@@ -13,8 +13,12 @@
namespace phpbb\db;
+use phpbb\config\config;
+use phpbb\db\driver\driver_interface;
+use phpbb\db\migration\helper;
use phpbb\db\output_handler\migrator_output_handler_interface;
use phpbb\db\output_handler\null_migrator_output_handler;
+use phpbb\db\tools\tools_interface;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
@@ -28,21 +32,24 @@ class migrator
*/
protected $container;
- /** @var \phpbb\config\config */
+ /** @var config */
protected $config;
- /** @var \phpbb\db\driver\driver_interface */
+ /** @var driver_interface */
protected $db;
- /** @var \phpbb\db\tools\tools_interface */
+ /** @var tools_interface */
protected $db_tools;
- /** @var \phpbb\db\migration\helper */
+ /** @var helper */
protected $helper;
/** @var string */
protected $table_prefix;
+ /** @var array */
+ protected $tables;
+
/** @var string */
protected $phpbb_root_path;
@@ -92,9 +99,20 @@ class migrator
protected $output_handler;
/**
- * Constructor of the database migrator
- */
- public function __construct(ContainerInterface $container, \phpbb\config\config $config, \phpbb\db\driver\driver_interface $db, \phpbb\db\tools\tools_interface $db_tools, $migrations_table, $phpbb_root_path, $php_ext, $table_prefix, $tools, \phpbb\db\migration\helper $helper)
+ * Constructor of the database migrator
+ * @param ContainerInterface $container
+ * @param config $config
+ * @param driver\driver_interface $db
+ * @param tools\tools_interface $db_tools
+ * @param $migrations_table
+ * @param $phpbb_root_path
+ * @param $php_ext
+ * @param $table_prefix
+ * @param $tables
+ * @param $tools
+ * @param migration\helper $helper
+ */
+ public function __construct(ContainerInterface $container, config $config, driver_interface $db, tools_interface $db_tools, $migrations_table, $phpbb_root_path, $php_ext, $table_prefix, $tables, $tools, helper $helper)
{
$this->container = $container;
$this->config = $config;
@@ -108,6 +126,7 @@ class migrator
$this->php_ext = $php_ext;
$this->table_prefix = $table_prefix;
+ $this->tables = $tables;
$this->output_handler = new null_migrator_output_handler();
@@ -950,7 +969,7 @@ class migrator
*/
protected function get_migration($name)
{
- $migration = new $name($this->config, $this->db, $this->db_tools, $this->phpbb_root_path, $this->php_ext, $this->table_prefix);
+ $migration = new $name($this->config, $this->db, $this->db_tools, $this->phpbb_root_path, $this->php_ext, $this->table_prefix, $this->tables);
if ($migration instanceof ContainerAwareInterface)
{
diff --git a/phpBB/phpbb/install/module/install_database/task/create_schema.php b/phpBB/phpbb/install/module/install_database/task/create_schema.php
index 204fddb20e..46529d1542 100644
--- a/phpBB/phpbb/install/module/install_database/task/create_schema.php
+++ b/phpBB/phpbb/install/module/install_database/task/create_schema.php
@@ -13,7 +13,14 @@
namespace phpbb\install\module\install_database\task;
+use phpbb\db\driver\driver_interface;
+use phpbb\db\migration\schema_generator;
+use phpbb\db\tools\tools_interface;
+use phpbb\filesystem\filesystem_interface;
use phpbb\install\exception\resource_limit_reached_exception;
+use phpbb\install\helper\config;
+use phpbb\install\helper\database;
+use phpbb\install\helper\iohandler\iohandler_interface;
/**
* Create database schema
@@ -21,32 +28,32 @@ use phpbb\install\exception\resource_limit_reached_exception;
class create_schema extends \phpbb\install\task_base
{
/**
- * @var \phpbb\install\helper\config
+ * @var config
*/
protected $config;
/**
- * @var \phpbb\db\driver\driver_interface
+ * @var driver_interface
*/
protected $db;
/**
- * @var \phpbb\db\tools\tools_interface
+ * @var tools_interface
*/
protected $db_tools;
/**
- * @var \phpbb\install\helper\database
+ * @var database
*/
protected $database_helper;
/**
- * @var \phpbb\filesystem\filesystem_interface
+ * @var filesystem_interface
*/
protected $filesystem;
/**
- * @var \phpbb\install\helper\iohandler\iohandler_interface
+ * @var iohandler_interface
*/
protected $iohandler;
@@ -61,21 +68,28 @@ class create_schema extends \phpbb\install\task_base
protected $php_ext;
/**
+ * @var array
+ */
+ protected $tables;
+
+ /**
* Constructor
*
- * @param \phpbb\install\helper\config $config Installer's config provider
- * @param \phpbb\install\helper\database $db_helper Installer's database helper
- * @param \phpbb\filesystem\filesystem_interface $filesystem Filesystem service
- * @param \phpbb\install\helper\iohandler\iohandler_interface $iohandler Installer's input-output handler
- * @param string $phpbb_root_path Path phpBB's root
- * @param string $php_ext Extension of PHP files
+ * @param config $config Installer's config provider
+ * @param database $db_helper Installer's database helper
+ * @param filesystem_interface $filesystem Filesystem service
+ * @param iohandler_interface $iohandler Installer's input-output handler
+ * @param string $phpbb_root_path Path phpBB's root
+ * @param string $php_ext Extension of PHP files
+ * @param array $tables Tables array
*/
- public function __construct(\phpbb\install\helper\config $config,
- \phpbb\install\helper\database $db_helper,
- \phpbb\filesystem\filesystem_interface $filesystem,
- \phpbb\install\helper\iohandler\iohandler_interface $iohandler,
+ public function __construct(config $config,
+ database $db_helper,
+ filesystem_interface $filesystem,
+ iohandler_interface $iohandler,
$phpbb_root_path,
- $php_ext)
+ $php_ext,
+ $tables)
{
$dbms = $db_helper->get_available_dbms($config->get('dbms'));
$dbms = $dbms[$config->get('dbms')]['DRIVER'];
@@ -99,6 +113,7 @@ class create_schema extends \phpbb\install\task_base
$this->iohandler = $iohandler;
$this->phpbb_root_path = $phpbb_root_path;
$this->php_ext = $php_ext;
+ $this->tables = $tables;
parent::__construct(true);
}
@@ -180,14 +195,15 @@ class create_schema extends \phpbb\install\task_base
$migrator_classes = $finder->core_path('phpbb/db/migration/data/')->get_classes();
$factory = new \phpbb\db\tools\factory();
$db_tools = $factory->get($this->db, true);
- $schema_generator = new \phpbb\db\migration\schema_generator(
+ $schema_generator = new schema_generator(
$migrator_classes,
new \phpbb\config\config(array()),
$this->db,
$db_tools,
$this->phpbb_root_path,
$this->php_ext,
- $table_prefix
+ $table_prefix,
+ $this->tables
);
$db_table_schema = $schema_generator->get_schema();
}
diff --git a/phpBB/phpbb/install/module/install_database/task/create_schema_file.php b/phpBB/phpbb/install/module/install_database/task/create_schema_file.php
index 81db66e11e..4dfaa07ebf 100644
--- a/phpBB/phpbb/install/module/install_database/task/create_schema_file.php
+++ b/phpBB/phpbb/install/module/install_database/task/create_schema_file.php
@@ -121,6 +121,13 @@ class create_schema_file extends \phpbb\install\task_base
$migrator_classes = $finder->core_path('phpbb/db/migration/data/')->get_classes();
$factory = new \phpbb\db\tools\factory();
$db_tools = $factory->get($this->db, true);
+ $tables_data = \Symfony\Component\Yaml\Yaml::parseFile($this->phpbb_root_path . '/config/default/container/tables.yml');
+ $tables = [];
+ foreach ($tables_data['parameters'] as $parameter => $table)
+ {
+ $tables[str_replace('tables.', '', $parameter)] = str_replace('%core.table_prefix%', $table_prefix, $table);
+ }
+
$schema_generator = new \phpbb\db\migration\schema_generator(
$migrator_classes,
new \phpbb\config\config(array()),
@@ -128,7 +135,8 @@ class create_schema_file extends \phpbb\install\task_base
$db_tools,
$this->phpbb_root_path,
$this->php_ext,
- $table_prefix
+ $table_prefix,
+ $tables
);
$db_table_schema = $schema_generator->get_schema();
$db_table_schema = json_encode($db_table_schema, JSON_PRETTY_PRINT);
diff --git a/tests/dbal/migrator_test.php b/tests/dbal/migrator_test.php
index 1f6cf3c8a3..947da726b3 100644
--- a/tests/dbal/migrator_test.php
+++ b/tests/dbal/migrator_test.php
@@ -69,6 +69,7 @@ class phpbb_dbal_migrator_test extends phpbb_database_test_case
dirname(__FILE__) . '/../../phpBB/',
'php',
'phpbb_',
+ self::get_core_tables(),
$tools,
new \phpbb\db\migration\helper()
);
diff --git a/tests/extension/manager_test.php b/tests/extension/manager_test.php
index 128192fa0c..5eac7d1951 100644
--- a/tests/extension/manager_test.php
+++ b/tests/extension/manager_test.php
@@ -167,6 +167,7 @@ class phpbb_extension_manager_test extends phpbb_database_test_case
$phpbb_root_path,
$php_ext,
$table_prefix,
+ self::get_core_tables(),
array(),
new \phpbb\db\migration\helper()
);
diff --git a/tests/extension/metadata_manager_test.php b/tests/extension/metadata_manager_test.php
index 38b821c7b4..2e1a85a013 100644
--- a/tests/extension/metadata_manager_test.php
+++ b/tests/extension/metadata_manager_test.php
@@ -87,6 +87,7 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case
$this->phpbb_root_path,
'php',
$this->table_prefix,
+ self::get_core_tables(),
array(),
new \phpbb\db\migration\helper()
);
diff --git a/tests/migrator/convert_timezones_test.php b/tests/migrator/convert_timezones_test.php
index 4bb0aec34f..5bb8d7ab93 100644
--- a/tests/migrator/convert_timezones_test.php
+++ b/tests/migrator/convert_timezones_test.php
@@ -64,7 +64,8 @@ class phpbb_migrator_convert_timezones_test extends phpbb_database_test_case
$factory->get($this->db),
$phpbb_root_path,
$phpEx,
- 'phpbb_'
+ 'phpbb_',
+ self::get_core_tables()
);
}
diff --git a/tests/migrator/get_callable_from_step_test.php b/tests/migrator/get_callable_from_step_test.php
index b0abb6199c..809b977d57 100644
--- a/tests/migrator/get_callable_from_step_test.php
+++ b/tests/migrator/get_callable_from_step_test.php
@@ -43,6 +43,7 @@ class get_callable_from_step_test extends phpbb_database_test_case
$phpbb_root_path,
$php_ext,
$table_prefix,
+ self::get_core_tables(),
array($module_tools),
new \phpbb\db\migration\helper()
);
diff --git a/tests/migrator/schema_generator_test.php b/tests/migrator/schema_generator_test.php
index 1349b98953..dd7158cbfd 100644
--- a/tests/migrator/schema_generator_test.php
+++ b/tests/migrator/schema_generator_test.php
@@ -41,7 +41,7 @@ class schema_generator_test extends phpbb_test_case
protected function get_schema_generator(array $class_names)
{
- $this->generator = new \phpbb\db\migration\schema_generator($class_names, $this->config, $this->db, $this->db_tools, $this->phpbb_root_path, $this->php_ext, $this->table_prefix);
+ $this->generator = new \phpbb\db\migration\schema_generator($class_names, $this->config, $this->db, $this->db_tools, $this->phpbb_root_path, $this->php_ext, $this->table_prefix, phpbb_database_test_case::get_core_tables());
return $this->generator;
}
diff --git a/tests/notification/convert_test.php b/tests/notification/convert_test.php
index d4a33ff537..d1707cc70f 100644
--- a/tests/notification/convert_test.php
+++ b/tests/notification/convert_test.php
@@ -36,7 +36,8 @@ class phpbb_notification_convert_test extends phpbb_database_test_case
$factory->get($this->db),
$phpbb_root_path,
$phpEx,
- 'phpbb_'
+ 'phpbb_',
+ self::get_core_tables()
);
}
diff --git a/tests/test_framework/phpbb_database_test_case.php b/tests/test_framework/phpbb_database_test_case.php
index ccd9044e65..5ef545781c 100644
--- a/tests/test_framework/phpbb_database_test_case.php
+++ b/tests/test_framework/phpbb_database_test_case.php
@@ -75,14 +75,13 @@ abstract class phpbb_database_test_case extends TestCase
if (!file_exists(self::$schema_file))
{
-
global $table_prefix;
$db = new \phpbb\db\driver\sqlite3();
$factory = new \phpbb\db\tools\factory();
$db_tools = $factory->get($db, true);
- $schema_generator = new \phpbb\db\migration\schema_generator($classes, new \phpbb\config\config(array()), $db, $db_tools, $phpbb_root_path, $phpEx, $table_prefix);
+ $schema_generator = new \phpbb\db\migration\schema_generator($classes, new \phpbb\config\config(array()), $db, $db_tools, $phpbb_root_path, $phpEx, $table_prefix, self::get_core_tables());
file_put_contents(self::$schema_file, json_encode($schema_generator->get_schema()));
}
@@ -353,4 +352,23 @@ abstract class phpbb_database_test_case extends TestCase
$this->assertTrue(true);
}
}
+
+ static public function get_core_tables() : array
+ {
+ global $phpbb_root_path, $table_prefix;
+
+ static $core_tables = [];
+
+ if (empty($tables))
+ {
+ $tables_yml_data = \Symfony\Component\Yaml\Yaml::parseFile($phpbb_root_path . '/config/default/container/tables.yml');
+
+ foreach ($tables_yml_data['parameters'] as $parameter => $table)
+ {
+ $core_tables[str_replace('tables.', '', $parameter)] = str_replace('%core.table_prefix%', $table_prefix, $table);
+ }
+ }
+
+ return $core_tables;
+ }
}
diff --git a/tests/test_framework/phpbb_database_test_connection_manager.php b/tests/test_framework/phpbb_database_test_connection_manager.php
index b6ad7e7838..e4c1a194cc 100644
--- a/tests/test_framework/phpbb_database_test_connection_manager.php
+++ b/tests/test_framework/phpbb_database_test_connection_manager.php
@@ -372,8 +372,9 @@ class phpbb_database_test_connection_manager
$db = new \phpbb\db\driver\sqlite3();
$factory = new \phpbb\db\tools\factory();
$db_tools = $factory->get($db, true);
+ $tables = phpbb_database_test_case::get_core_tables();
- $schema_generator = new \phpbb\db\migration\schema_generator($classes, new \phpbb\config\config(array()), $db, $db_tools, $phpbb_root_path, $phpEx, $table_prefix);
+ $schema_generator = new \phpbb\db\migration\schema_generator($classes, new \phpbb\config\config(array()), $db, $db_tools, $phpbb_root_path, $phpEx, $table_prefix, $tables);
$db_table_schema = $schema_generator->get_schema();
}
diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php
index abf83d777b..4f7271e313 100644
--- a/tests/test_framework/phpbb_functional_test_case.php
+++ b/tests/test_framework/phpbb_functional_test_case.php
@@ -249,6 +249,7 @@ class phpbb_functional_test_case extends phpbb_test_case
$phpbb_root_path,
$phpEx,
self::$config['table_prefix'],
+ phpbb_database_test_case::get_core_tables(),
array(),
new \phpbb\db\migration\helper()
);
diff --git a/tests/test_framework/phpbb_ui_test_case.php b/tests/test_framework/phpbb_ui_test_case.php
index 61db3da3e9..1fbfd22dbe 100644
--- a/tests/test_framework/phpbb_ui_test_case.php
+++ b/tests/test_framework/phpbb_ui_test_case.php
@@ -486,6 +486,7 @@ class phpbb_ui_test_case extends phpbb_test_case
$phpbb_root_path,
$phpEx,
self::$config['table_prefix'],
+ phpbb_database_test_case::get_core_tables(),
array(),
new \phpbb\db\migration\helper()
);