diff --git a/phpBB/config/default/container/services_db.yml b/phpBB/config/default/container/services_db.yml index bad99b7d87..4ead52126c 100644 --- a/phpBB/config/default/container/services_db.yml +++ b/phpBB/config/default/container/services_db.yml @@ -8,7 +8,9 @@ services: synthetic: true dbal.conn.doctrine: - synthetic: true + class: Doctrine\DBAL\Connection + factory: ['phpbb\db\doctrine\connection_factory', 'get_connection'] + arguments: ['@config.php'] # ----- DB Tools ----- dbal.tools.factory: diff --git a/phpBB/phpbb/db/doctrine/comparator.php b/phpBB/phpbb/db/doctrine/comparator.php index 27390e3da0..4a3d3c14f6 100644 --- a/phpBB/phpbb/db/doctrine/comparator.php +++ b/phpBB/phpbb/db/doctrine/comparator.php @@ -4,7 +4,7 @@ * This file is part of the phpBB Forum Software package. * * @copyright (c) phpBB Limited - * @license GNU General Public License, version 2 (GPL-2.0) + * @license GNU General Public License, version 2 (GPL-2.0) * * For full copyright and license information, please see * the docs/CREDITS.txt file. @@ -50,7 +50,7 @@ class comparator extends \Doctrine\DBAL\Schema\Comparator } $index_columns = array_map('strtolower', $index->getUnquotedColumns()); - if (array_search($columnName, $index_columns, true) === false) + if (!in_array($columnName, $index_columns, true)) { continue; } diff --git a/phpBB/phpbb/db/doctrine/connection_factory.php b/phpBB/phpbb/db/doctrine/connection_factory.php index 4d2c2f55e6..b692309688 100644 --- a/phpBB/phpbb/db/doctrine/connection_factory.php +++ b/phpBB/phpbb/db/doctrine/connection_factory.php @@ -4,7 +4,7 @@ * This file is part of the phpBB Forum Software package. * * @copyright (c) phpBB Limited - * @license GNU General Public License, version 2 (GPL-2.0) + * @license GNU General Public License, version 2 (GPL-2.0) * * For full copyright and license information, please see * the docs/CREDITS.txt file. diff --git a/phpBB/phpbb/db/doctrine/oci8/connection.php b/phpBB/phpbb/db/doctrine/oci8/connection.php index 98d11c2fbe..6f7f0aa3b9 100644 --- a/phpBB/phpbb/db/doctrine/oci8/connection.php +++ b/phpBB/phpbb/db/doctrine/oci8/connection.php @@ -4,7 +4,7 @@ * This file is part of the phpBB Forum Software package. * * @copyright (c) phpBB Limited - * @license GNU General Public License, version 2 (GPL-2.0) + * @license GNU General Public License, version 2 (GPL-2.0) * * For full copyright and license information, please see * the docs/CREDITS.txt file. @@ -18,7 +18,7 @@ use Doctrine\DBAL\Driver\Result as DriverResult; use Doctrine\DBAL\Driver\Statement as DriverStatement; use Doctrine\DBAL\ParameterType; -class Connection implements DriverConnection +class connection implements DriverConnection { /** * @var DriverConnection @@ -68,7 +68,7 @@ class Connection implements DriverConnection /** * {@inheritDoc} */ - public function lastInsertId($name = null) + public function lastInsertId($name = null): ?string { return $this->wrapped->lastInsertId($name); } @@ -76,7 +76,7 @@ class Connection implements DriverConnection /** * {@inheritDoc} */ - public function beginTransaction() + public function beginTransaction(): bool { return $this->wrapped->beginTransaction(); } @@ -84,7 +84,7 @@ class Connection implements DriverConnection /** * {@inheritDoc} */ - public function commit() + public function commit(): bool { return $this->wrapped->commit(); } @@ -92,7 +92,7 @@ class Connection implements DriverConnection /** * {@inheritDoc} */ - public function rollBack() + public function rollBack(): bool { return $this->wrapped->rollBack(); } diff --git a/phpBB/phpbb/db/doctrine/oci8/driver.php b/phpBB/phpbb/db/doctrine/oci8/driver.php index 0a5300092c..9a2c67aee0 100644 --- a/phpBB/phpbb/db/doctrine/oci8/driver.php +++ b/phpBB/phpbb/db/doctrine/oci8/driver.php @@ -4,7 +4,7 @@ * This file is part of the phpBB Forum Software package. * * @copyright (c) phpBB Limited - * @license GNU General Public License, version 2 (GPL-2.0) + * @license GNU General Public License, version 2 (GPL-2.0) * * For full copyright and license information, please see * the docs/CREDITS.txt file. diff --git a/phpBB/phpbb/db/doctrine/oci8/result.php b/phpBB/phpbb/db/doctrine/oci8/result.php index 60072bfe9f..1ab1085427 100644 --- a/phpBB/phpbb/db/doctrine/oci8/result.php +++ b/phpBB/phpbb/db/doctrine/oci8/result.php @@ -4,7 +4,7 @@ * This file is part of the phpBB Forum Software package. * * @copyright (c) phpBB Limited - * @license GNU General Public License, version 2 (GPL-2.0) + * @license GNU General Public License, version 2 (GPL-2.0) * * For full copyright and license information, please see * the docs/CREDITS.txt file. diff --git a/phpBB/phpbb/db/doctrine/oci8/schema_manager.php b/phpBB/phpbb/db/doctrine/oci8/schema_manager.php index aeb1120e12..c0b2caea1d 100644 --- a/phpBB/phpbb/db/doctrine/oci8/schema_manager.php +++ b/phpBB/phpbb/db/doctrine/oci8/schema_manager.php @@ -4,7 +4,7 @@ * This file is part of the phpBB Forum Software package. * * @copyright (c) phpBB Limited - * @license GNU General Public License, version 2 (GPL-2.0) + * @license GNU General Public License, version 2 (GPL-2.0) * * For full copyright and license information, please see * the docs/CREDITS.txt file. diff --git a/phpBB/phpbb/db/doctrine/oci8/statement.php b/phpBB/phpbb/db/doctrine/oci8/statement.php index 332c3fab32..bca22473c4 100644 --- a/phpBB/phpbb/db/doctrine/oci8/statement.php +++ b/phpBB/phpbb/db/doctrine/oci8/statement.php @@ -4,7 +4,7 @@ * This file is part of the phpBB Forum Software package. * * @copyright (c) phpBB Limited - * @license GNU General Public License, version 2 (GPL-2.0) + * @license GNU General Public License, version 2 (GPL-2.0) * * For full copyright and license information, please see * the docs/CREDITS.txt file. @@ -35,7 +35,7 @@ class statement implements DriverStatement /** * {@inheritDoc} */ - public function bindValue($param, $value, $type = ParameterType::STRING) + public function bindValue($param, $value, $type = ParameterType::STRING): bool { return $this->wrapped->bindValue($param, $value, $type); } @@ -43,7 +43,7 @@ class statement implements DriverStatement /** * {@inheritDoc} */ - public function bindParam($param, &$variable, $type = ParameterType::STRING, $length = null) + public function bindParam($param, &$variable, $type = ParameterType::STRING, $length = null): bool { return $this->wrapped->bindParam($param, $variable, $type, $length); } diff --git a/phpBB/phpbb/db/doctrine/oracle_platform.php b/phpBB/phpbb/db/doctrine/oracle_platform.php index 43ace17795..7d9e4a7c28 100644 --- a/phpBB/phpbb/db/doctrine/oracle_platform.php +++ b/phpBB/phpbb/db/doctrine/oracle_platform.php @@ -47,7 +47,7 @@ class oracle_platform extends OraclePlatform /** * {@inheritDoc} */ - public function getCreateIndexSQL(Index $index, $table) + public function getCreateIndexSQL(Index $index, $table): string { if ($table instanceof Table) { @@ -79,12 +79,12 @@ class oracle_platform extends OraclePlatform /** * Check whether the index name is too long * - * @param string $table_name - * @param string $index_name - * @param bool $throw_error + * @param string $table_name + * @param string $index_name + * @param bool $throw_error * @return string The index name, shortened if too long */ - protected function check_index_name_length($table_name, $index_name, $throw_error = true) + protected function check_index_name_length(string $table_name, string $index_name, bool $throw_error = true): string { $max_index_name_length = $this->getMaxIdentifierLength(); if (strlen($index_name) > $max_index_name_length) @@ -108,7 +108,9 @@ class oracle_platform extends OraclePlatform if ($throw_error) { - trigger_error("Index name '$index_name' on table '$table_name' is too long. The maximum is $max_index_name_length characters.", E_USER_ERROR); + throw new \InvalidArgumentException( + "Index name '$index_name' on table '$table_name' is too long. The maximum is $max_index_name_length characters." + ); } } @@ -118,9 +120,9 @@ class oracle_platform extends OraclePlatform /** * {@inheritdoc} */ - public function getIdentitySequenceName($tableName, $columnName) + public function getIdentitySequenceName($tableName, $columnName): string { - return $tableName.'_SEQ'; + return $tableName . '_SEQ'; } /** @@ -140,7 +142,7 @@ class oracle_platform extends OraclePlatform /** * @see OraclePlatform::normalizeIdentifier() */ - private function doctrine_normalize_identifier($name) + private function doctrine_normalize_identifier($name): Identifier { $identifier = new Identifier($name); @@ -150,7 +152,7 @@ class oracle_platform extends OraclePlatform /** * @see OraclePlatform::getAutoincrementIdentifierName() */ - private function get_doctrine_autoincrement_identifier_name(Identifier $table) + private function get_doctrine_autoincrement_identifier_name(Identifier $table): string { $identifierName = $this->add_doctrine_Suffix($table->getName(), '_AI_PK'); diff --git a/phpBB/phpbb/db/doctrine/postgresql_platform.php b/phpBB/phpbb/db/doctrine/postgresql_platform.php index 197f9ac386..5ebff66200 100644 --- a/phpBB/phpbb/db/doctrine/postgresql_platform.php +++ b/phpBB/phpbb/db/doctrine/postgresql_platform.php @@ -95,7 +95,7 @@ class postgresql_platform extends PostgreSQL94Platform $post_sql = []; foreach ($columns as $column_name => $column) { - if (! empty($column['autoincrement'])) + if (!empty($column['autoincrement'])) { $sequence = new Sequence($this->getIdentitySequenceName($name, $column_name)); $sql[] = $this->getCreateSequenceSQL($sequence); @@ -113,7 +113,8 @@ class postgresql_platform extends PostgreSQL94Platform } /** - * @param mixed[] $column + * @param array $column + * @return bool */ private function isSerialColumn(array $column): bool { @@ -138,7 +139,7 @@ class postgresql_platform extends PostgreSQL94Platform 1 AS increment_by FROM information_schema.sequences WHERE sequence_schema NOT LIKE 'pg\_%' - AND sequence_schema != 'information_schema'"; + AND sequence_schema <> 'information_schema'"; } /** diff --git a/phpBB/phpbb/db/doctrine/sqlsrv_platform.php b/phpBB/phpbb/db/doctrine/sqlsrv_platform.php index 58deed2423..aa7c9bc241 100644 --- a/phpBB/phpbb/db/doctrine/sqlsrv_platform.php +++ b/phpBB/phpbb/db/doctrine/sqlsrv_platform.php @@ -4,7 +4,7 @@ * This file is part of the phpBB Forum Software package. * * @copyright (c) phpBB Limited - * @license GNU General Public License, version 2 (GPL-2.0) + * @license GNU General Public License, version 2 (GPL-2.0) * * For full copyright and license information, please see * the docs/CREDITS.txt file. @@ -37,7 +37,7 @@ class sqlsrv_platform extends SQLServer2012Platform $this->generate_doctrine_identifier_name($column['name']), ], [ $table, - $column['name'].'_1', + $column['name'] . '_1', ], $sql); } @@ -70,7 +70,7 @@ class sqlsrv_platform extends SQLServer2012Platform $phpbb_names[] = $diff->name; // NEW Table name if relevant - if ($diff->getNewName() != null) + if ($diff->getNewName()) { $doctrine_names[] = $this->generate_doctrine_identifier_name($diff->getNewName()->getName()); $phpbb_names[] = $diff->getNewName()->getName(); @@ -79,30 +79,30 @@ class sqlsrv_platform extends SQLServer2012Platform foreach ($diff->addedColumns as $column) { $doctrine_names[] = $this->generate_doctrine_identifier_name($column->getQuotedName($this)); - $phpbb_names[] = $column->getQuotedName($this).'_1'; + $phpbb_names[] = $column->getQuotedName($this) . '_1'; } foreach ($diff->removedColumns as $column) { $doctrine_names[] = $this->generate_doctrine_identifier_name($column->getQuotedName($this)); - $phpbb_names[] = $column->getQuotedName($this).'_1'; + $phpbb_names[] = $column->getQuotedName($this) . '_1'; } foreach ($diff->renamedColumns as $column) { $doctrine_names[] = $this->generate_doctrine_identifier_name($column->getQuotedName($this)); - $phpbb_names[] = $column->getQuotedName($this).'_1'; + $phpbb_names[] = $column->getQuotedName($this) . '_1'; } foreach ($diff->changedColumns as $column) { $doctrine_names[] = $this->generate_doctrine_identifier_name($column->column->getQuotedName($this)); - $phpbb_names[] = $column->column->getQuotedName($this).'_1'; + $phpbb_names[] = $column->column->getQuotedName($this) . '_1'; if ($column->oldColumnName != $column->column->getQuotedName($this)) { $doctrine_names[] = $this->generate_doctrine_identifier_name($column->oldColumnName); - $phpbb_names[] = $column->oldColumnName.'_1'; + $phpbb_names[] = $column->oldColumnName . '_1'; } } @@ -116,7 +116,7 @@ class sqlsrv_platform extends SQLServer2012Platform * * @return string */ - private function generate_doctrine_identifier_name($identifier) + private function generate_doctrine_identifier_name(string $identifier): string { // Always generate name for unquoted identifiers to ensure consistency. $identifier = new Identifier($identifier); @@ -132,7 +132,7 @@ class sqlsrv_platform extends SQLServer2012Platform * * @return string */ - private function generate_doctrine_default_constraint_name($table, $column) + private function generate_doctrine_default_constraint_name(string $table, string $column): string { return 'DF_' . $this->generate_doctrine_identifier_name($table) . '_' . $this->generate_doctrine_identifier_name($column); } diff --git a/phpBB/phpbb/db/doctrine/table_helper.php b/phpBB/phpbb/db/doctrine/table_helper.php index 422c71a240..92f2069715 100644 --- a/phpBB/phpbb/db/doctrine/table_helper.php +++ b/phpBB/phpbb/db/doctrine/table_helper.php @@ -4,13 +4,12 @@ * This file is part of the phpBB Forum Software package. * * @copyright (c) phpBB Limited - * @license GNU General Public License, version 2 (GPL-2.0) + * @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\doctrine; use InvalidArgumentException; diff --git a/phpBB/phpbb/db/tools/doctrine.php b/phpBB/phpbb/db/tools/doctrine.php index 631e4dc811..14c5aede2a 100644 --- a/phpBB/phpbb/db/tools/doctrine.php +++ b/phpBB/phpbb/db/tools/doctrine.php @@ -4,7 +4,7 @@ * This file is part of the phpBB Forum Software package. * * @copyright (c) phpBB Limited - * @license GNU General Public License, version 2 (GPL-2.0) + * @license GNU General Public License, version 2 (GPL-2.0) * * For full copyright and license information, please see * the docs/CREDITS.txt file. @@ -32,7 +32,7 @@ use phpbb\db\doctrine\table_helper; * In general, it is recommended to use Doctrine directly instead of this class as this * implementation is only a BC layer. */ -class doctrine implements tools_interface, tools +class doctrine implements tools_interface { /** * @var AbstractSchemaManager @@ -181,49 +181,49 @@ class doctrine implements tools_interface, tools return; } - return $this->_alter_schema( + return $this->alter_schema( function (Schema $schema) use($schema_changes): void { $mapping = [ 'drop_tables' => [ - 'method' => '_schema_drop_table', + 'method' => 'schema_drop_table', 'use_key' => false, ], 'add_tables' => [ - 'method' => '_schema_create_table', + 'method' => 'schema_create_table', 'use_key' => true, ], 'change_columns' => [ - 'method' => '_schema_column_change_add', + 'method' => 'schema_column_change_add', 'use_key' => true, 'per_table' => true, ], 'add_columns' => [ - 'method' => '_schema_column_add', + 'method' => 'schema_column_add', 'use_key' => true, 'per_table' => true, ], 'drop_columns' => [ - 'method' => '_schema_column_remove', + 'method' => 'schema_column_remove', 'use_key' => false, 'per_table' => true, ], 'drop_keys' => [ - 'method' => '_schema_index_drop', + 'method' => 'schema_index_drop', 'use_key' => false, 'per_table' => true, ], 'add_primary_keys' => [ - 'method' => '_schema_create_primary_key', + 'method' => 'schema_create_primary_key', 'use_key' => true, ], 'add_unique_index' => [ - 'method' => '_schema_create_unique_index', + 'method' => 'schema_create_unique_index', 'use_key' => true, 'per_table' => true, ], 'add_index' => [ - 'method' => '_schema_create_index', + 'method' => 'schema_create_index', 'use_key' => true, 'per_table' => true, ], @@ -233,12 +233,10 @@ class doctrine implements tools_interface, tools { if (array_key_exists($action, $schema_changes)) { - foreach ($schema_changes[$action] as $key => $data) + foreach ($schema_changes[$action] as $table_name => $table_data) { if (array_key_exists('per_table', $params) && $params['per_table']) { - $table_name = $key; - $table_data = $data; foreach ($table_data as $key => $data) { if ($params['use_key'] == false) @@ -255,11 +253,11 @@ class doctrine implements tools_interface, tools { if ($params['use_key'] == false) { - $this->{$params['method']}($schema, $data, true); + $this->{$params['method']}($schema, $table_data, true); } else { - $this->{$params['method']}($schema, $key, $data, true); + $this->{$params['method']}($schema, $table_name, $table_data, true); } } } @@ -274,10 +272,10 @@ class doctrine implements tools_interface, tools */ public function sql_create_table(string $table_name, array $table_data) { - return $this->_alter_schema( + return $this->alter_schema( function (Schema $schema) use ($table_name, $table_data): void { - $this->_schema_create_table($schema, $table_name, $table_data, true); + $this->schema_create_table($schema, $table_name, $table_data, true); } ); } @@ -287,10 +285,10 @@ class doctrine implements tools_interface, tools */ public function sql_table_drop(string $table_name) { - return $this->_alter_schema( + return $this->alter_schema( function (Schema $schema) use ($table_name): void { - $this->_schema_drop_table($schema, $table_name, true); + $this->schema_drop_table($schema, $table_name, true); } ); } @@ -300,10 +298,10 @@ class doctrine implements tools_interface, tools */ public function sql_column_add(string $table_name, string $column_name, array $column_data) { - return $this->_alter_schema( + return $this->alter_schema( function (Schema $schema) use ($table_name, $column_name, $column_data): void { - $this->_schema_column_add($schema, $table_name, $column_name, $column_data); + $this->schema_column_add($schema, $table_name, $column_name, $column_data); } ); } @@ -313,10 +311,10 @@ class doctrine implements tools_interface, tools */ public function sql_column_change(string $table_name, string $column_name, array $column_data) { - return $this->_alter_schema( + return $this->alter_schema( function (Schema $schema) use ($table_name, $column_name, $column_data): void { - $this->_schema_column_change($schema, $table_name, $column_name, $column_data); + $this->schema_column_change($schema, $table_name, $column_name, $column_data); } ); } @@ -326,10 +324,10 @@ class doctrine implements tools_interface, tools */ public function sql_column_remove(string $table_name, string $column_name) { - return $this->_alter_schema( + return $this->alter_schema( function (Schema $schema) use ($table_name, $column_name): void { - $this->_schema_column_remove($schema, $table_name, $column_name); + $this->schema_column_remove($schema, $table_name, $column_name); } ); } @@ -339,10 +337,10 @@ class doctrine implements tools_interface, tools */ public function sql_create_index(string $table_name, string $index_name, $column) { - return $this->_alter_schema( + return $this->alter_schema( function (Schema $schema) use ($table_name, $index_name, $column): void { - $this->_schema_create_index($column, $schema, $table_name, $index_name); + $this->schema_create_index($column, $schema, $table_name, $index_name); } ); } @@ -352,10 +350,10 @@ class doctrine implements tools_interface, tools */ public function sql_index_drop(string $table_name, string $index_name) { - return $this->_alter_schema( + return $this->alter_schema( function (Schema $schema) use ($table_name, $index_name): void { - $this->_schema_index_drop($schema, $table_name, $index_name); + $this->schema_index_drop($schema, $table_name, $index_name); } ); } @@ -365,10 +363,10 @@ class doctrine implements tools_interface, tools */ public function sql_create_unique_index(string $table_name, string $index_name, $column) { - return $this->_alter_schema( + return $this->alter_schema( function (Schema $schema) use ($table_name, $index_name, $column): void { - $this->_schema_create_unique_index($column, $schema, $table_name, $index_name); + $this->schema_create_unique_index($column, $schema, $table_name, $index_name); } ); } @@ -378,10 +376,10 @@ class doctrine implements tools_interface, tools */ public function sql_create_primary_key(string $table_name, $column) { - return $this->_alter_schema( + return $this->alter_schema( function (Schema $schema) use ($table_name, $column): void { - $this->_schema_create_primary_key($schema, $column, $table_name); + $this->schema_create_primary_key($schema, $column, $table_name); } ); } @@ -458,7 +456,7 @@ class doctrine implements tools_interface, tools * * @return bool|string[] */ - protected function _alter_schema(callable $callback) + protected function alter_schema(callable $callback) { try { @@ -514,7 +512,7 @@ class doctrine implements tools_interface, tools * * @throws SchemaException */ - protected function _schema_create_table(Schema $schema, string $table_name, array $table_data, bool $safe_check = false): void + protected function schema_create_table(Schema $schema, string $table_name, array $table_data, bool $safe_check = false): void { if ($safe_check && $this->sql_table_exists($table_name)) { @@ -585,7 +583,7 @@ class doctrine implements tools_interface, tools * * @throws SchemaException */ - protected function _schema_drop_table(Schema $schema, string $table_name, bool $safe_check = false): void + protected function schema_drop_table(Schema $schema, string $table_name, bool $safe_check = false): void { if ($safe_check && !$schema->hasTable($table_name)) { @@ -604,7 +602,7 @@ class doctrine implements tools_interface, tools * * @throws SchemaException */ - protected function _schema_column_add(Schema $schema, string $table_name, string $column_name, array $column_data, bool $safe_check = false): void + protected function schema_column_add(Schema $schema, string $table_name, string $column_name, array $column_data, bool $safe_check = false): void { $this->alter_table( $schema, @@ -634,7 +632,7 @@ class doctrine implements tools_interface, tools * * @throws SchemaException */ - protected function _schema_column_change(Schema $schema, string $table_name, string $column_name, array $column_data, bool $safe_check = false): void + protected function schema_column_change(Schema $schema, string $table_name, string $column_name, array $column_data, bool $safe_check = false): void { $this->alter_table( $schema, @@ -659,7 +657,7 @@ class doctrine implements tools_interface, tools $index_columns = array_map('strtolower', $index->getUnquotedColumns()); if (array_search($column_name, $index_columns, true) !== false) { - $this->_recreate_index($table, $index, $index_columns); + $this->recreate_index($table, $index, $index_columns); } } } @@ -675,16 +673,16 @@ class doctrine implements tools_interface, tools * * @throws SchemaException */ - protected function _schema_column_change_add(Schema $schema, string $table_name, string $column_name, array $column_data, bool $safe_check = false): void + protected function schema_column_change_add(Schema $schema, string $table_name, string $column_name, array $column_data, bool $safe_check = false): void { $table = $schema->getTable($table_name); if ($table->hasColumn($column_name)) { - $this->_schema_column_change($schema, $table_name, $column_name, $column_data, $safe_check); + $this->schema_column_change($schema, $table_name, $column_name, $column_data, $safe_check); } else { - $this->_schema_column_add($schema, $table_name, $column_name, $column_data, $safe_check); + $this->schema_column_add($schema, $table_name, $column_name, $column_data, $safe_check); } } @@ -696,7 +694,7 @@ class doctrine implements tools_interface, tools * * @throws SchemaException */ - protected function _schema_column_remove(Schema $schema, string $table_name, string $column_name, bool $safe_check = false): void + protected function schema_column_remove(Schema $schema, string $table_name, string $column_name, bool $safe_check = false): void { $this->alter_table( $schema, @@ -731,7 +729,7 @@ class doctrine implements tools_interface, tools if ($key !== false) { unset($index_columns[$key]); - $this->_recreate_index($table, $index, $index_columns); + $this->recreate_index($table, $index, $index_columns); } } $table->dropColumn($column_name); @@ -748,7 +746,7 @@ class doctrine implements tools_interface, tools * * @throws SchemaException */ - protected function _schema_create_index($column, Schema $schema, string $table_name, string $index_name, bool $safe_check = false): void + protected function schema_create_index($column, Schema $schema, string $table_name, string $index_name, bool $safe_check = false): void { $columns = (is_array($column)) ? $column : [$column]; $table = $schema->getTable($table_name); @@ -770,7 +768,7 @@ class doctrine implements tools_interface, tools * * @throws SchemaException */ - protected function _schema_create_unique_index($column, Schema $schema, string $table_name, string $index_name, bool $safe_check = false): void + protected function schema_create_unique_index($column, Schema $schema, string $table_name, string $index_name, bool $safe_check = false): void { $columns = (is_array($column)) ? $column : [$column]; $table = $schema->getTable($table_name); @@ -791,7 +789,7 @@ class doctrine implements tools_interface, tools * * @throws SchemaException */ - protected function _schema_index_drop(Schema $schema, string $table_name, string $index_name, bool $safe_check = false): void + protected function schema_index_drop(Schema $schema, string $table_name, string $index_name, bool $safe_check = false): void { $table = $schema->getTable($table_name); @@ -811,7 +809,7 @@ class doctrine implements tools_interface, tools * * @throws SchemaException */ - protected function _schema_create_primary_key(Schema $schema, $column, string $table_name, bool $safe_check = false): void + protected function schema_create_primary_key(Schema $schema, $column, string $table_name, bool $safe_check = false): void { $columns = (is_array($column)) ? $column : [$column]; $table = $schema->getTable($table_name); @@ -828,7 +826,7 @@ class doctrine implements tools_interface, tools * * @throws SchemaException */ - protected function _recreate_index(Table $table, Index $index, array $new_columns): void + protected function recreate_index(Table $table, Index $index, array $new_columns): void { if ($index->isPrimary()) { diff --git a/phpBB/phpbb/db/tools/tools.php b/phpBB/phpbb/db/tools/tools.php index 822df4d6ca..5036f78dc4 100644 --- a/phpBB/phpbb/db/tools/tools.php +++ b/phpBB/phpbb/db/tools/tools.php @@ -19,6 +19,6 @@ namespace phpbb\db\tools; * * @deprecated 4.0.0-a1 */ -interface tools extends tools_interface +class tools extends doctrine { } diff --git a/phpBB/phpbb/db/tools/tools_interface.php b/phpBB/phpbb/db/tools/tools_interface.php index 717f2c5a4e..498a2a8828 100644 --- a/phpBB/phpbb/db/tools/tools_interface.php +++ b/phpBB/phpbb/db/tools/tools_interface.php @@ -4,7 +4,7 @@ * This file is part of the phpBB Forum Software package. * * @copyright (c) phpBB Limited - * @license GNU General Public License, version 2 (GPL-2.0) + * @license GNU General Public License, version 2 (GPL-2.0) * * For full copyright and license information, please see * the docs/CREDITS.txt file. diff --git a/phpBB/phpbb/di/container_builder.php b/phpBB/phpbb/di/container_builder.php index 6631800a8a..cca641403b 100644 --- a/phpBB/phpbb/di/container_builder.php +++ b/phpBB/phpbb/di/container_builder.php @@ -13,7 +13,6 @@ namespace phpbb\di; -use phpbb\db\doctrine\connection_factory; use Symfony\Bridge\ProxyManager\LazyProxy\PhpDumper\ProxyDumper; use Symfony\Component\Config\ConfigCache; use Symfony\Component\Config\FileLocator; @@ -51,16 +50,6 @@ class container_builder */ protected $container; - /** - * @var \phpbb\db\driver\driver_interface - */ - protected $dbal_connection = null; - - /** - * @var \Doctrine\DBAL\Connection - */ - private $dbal_connection_doctrine; - /** * Indicates whether extensions should be used (default to true). * @@ -579,24 +568,20 @@ class container_builder $config_data = $this->config_php_file->get_all(); if (!empty($config_data)) { - if ($this->dbal_connection === null) - { - $dbal_driver_class = \phpbb\config_php_file::convert_30_dbms_to_31($this->config_php_file->get('dbms')); - /** @var \phpbb\db\driver\driver_interface $dbal_connection */ - $this->dbal_connection = new $dbal_driver_class(); - $this->dbal_connection->sql_connect( - $this->config_php_file->get('dbhost'), - $this->config_php_file->get('dbuser'), - $this->config_php_file->get('dbpasswd'), - $this->config_php_file->get('dbname'), - $this->config_php_file->get('dbport'), - false, - defined('PHPBB_DB_NEW_LINK') && PHPBB_DB_NEW_LINK - ); - $this->dbal_connection_doctrine = connection_factory::get_connection($this->config_php_file); - } - $this->container->set('dbal.conn.driver', $this->dbal_connection); - $this->container->set('dbal.conn.doctrine', $this->dbal_connection_doctrine); + $dbal_driver_class = \phpbb\config_php_file::convert_30_dbms_to_31($this->config_php_file->get('dbms')); + /** @var \phpbb\db\driver\driver_interface $dbal_connection */ + $dbal_connection = new $dbal_driver_class(); + $dbal_connection->sql_connect( + $this->config_php_file->get('dbhost'), + $this->config_php_file->get('dbuser'), + $this->config_php_file->get('dbpasswd'), + $this->config_php_file->get('dbname'), + $this->config_php_file->get('dbport'), + false, + defined('PHPBB_DB_NEW_LINK') && PHPBB_DB_NEW_LINK + ); + //$this->dbal_connection_doctrine = connection_factory::get_connection($this->config_php_file); + $this->container->set('dbal.conn.driver', $dbal_connection); } } diff --git a/tests/dbal/db_tools_test.php b/tests/dbal/db_tools_test.php index 186f016a1d..f6344abdb2 100644 --- a/tests/dbal/db_tools_test.php +++ b/tests/dbal/db_tools_test.php @@ -386,7 +386,7 @@ class phpbb_dbal_db_tools_test extends phpbb_database_test_case public function test_perform_schema_changes_drop_columns() { $db_tools = $this->getMockBuilder('\phpbb\db\tools\doctrine') - ->onlyMethods(array('sql_column_exists', '_schema_column_remove')) + ->onlyMethods(array('sql_column_exists', 'schema_column_remove')) ->setConstructorArgs(array($this->doctrine_db)) ->getMock(); @@ -397,7 +397,7 @@ class phpbb_dbal_db_tools_test extends phpbb_database_test_case ->will($this->returnValue(true)); // drop columns - $db_tools->expects($this->exactly(2))->method('_schema_column_remove') + $db_tools->expects($this->exactly(2))->method('schema_column_remove') ->withConsecutive( [$this->isInstanceOf(Schema::class), 'existing_table', 'dropped_column_1', true], [$this->isInstanceOf(Schema::class), 'existing_table', 'dropped_column_2', true]