[ticket/16741] General fixes

PHPBB3-16741
This commit is contained in:
Tristan Darricau 2021-11-09 02:48:34 +01:00
parent 300e5399f5
commit 6ce708539b
20 changed files with 941 additions and 385 deletions

View file

@ -7,7 +7,6 @@ imports:
- { resource: services_content.yml }
- { resource: services_cron.yml }
- { resource: services_db.yml }
- { resource: services_doctrine.yml }
- { resource: services_event.yml }
- { resource: services_extensions.yml }
- { resource: services_feed.yml }

View file

@ -7,7 +7,10 @@ services:
dbal.conn.driver:
synthetic: true
# ----- DB Tools -----
dbal.conn.doctrine:
synthetic: true
# ----- DB Tools -----
dbal.tools.factory:
class: phpbb\db\tools\factory
@ -15,7 +18,7 @@ services:
class: phpbb\db\tools\tools_interface
factory: ['@dbal.tools.factory', get]
arguments:
- '@dbal.conn.driver'
- '@dbal.conn.doctrine'
# ----- DB Extractor -----
dbal.extractor.factory:

View file

@ -1,5 +0,0 @@
services:
doctrine.connection:
class: Doctrine\DBAL\Connection
factory: ['phpbb\db\doctrine\connection_factory', 'get_connection']
arguments: ['@config.php']

View file

@ -49,8 +49,15 @@ $classes = $finder->core_path('phpbb/')
->get_classes();
$db = new \phpbb\db\driver\sqlite3();
// The database is not used by db\tools when we generate the schema but it requires a doctrine DBAL object
// which always tries to connect to the database in the constructor. Which means if we want a valid doctrine
// Connection object that is not connected to any database we have to do that.
$ref = new ReflectionClass(\Doctrine\DBAL\Connection::class);
$db_doctrine = $ref->newInstanceWithoutConstructor();
$factory = new \phpbb\db\tools\factory();
$db_tools = $factory->get($db, true);
$db_tools = $factory->get($db_doctrine, true);
$tables_data = \Symfony\Component\Yaml\Yaml::parseFile($phpbb_root_path . '/config/default/container/tables.yml');
$tables = [];

View file

@ -365,10 +365,7 @@ function request_var($var_name, $default, $multibyte = false, $cookie = false, $
*/
function get_tables($db)
{
$db_tools_factory = new \phpbb\db\tools\factory();
$db_tools = $db_tools_factory->get($db);
return $db_tools->sql_list_tables();
throw new BadFunctionCallException('function removed from phpBB core, use db_tools service instead.');
}
/**

View file

@ -14,6 +14,7 @@
namespace phpbb\convert\controller;
use phpbb\cache\driver\driver_interface;
use phpbb\db\doctrine\connection_factory;
use phpbb\exception\http_exception;
use phpbb\install\controller\helper;
use phpbb\install\helper\container_factory;
@ -25,6 +26,7 @@ use phpbb\install\helper\navigation\navigation_provider;
use phpbb\language\language;
use phpbb\request\request_interface;
use phpbb\template\template;
use PHPUnit\DbUnit\Database\Connection;
use Symfony\Component\HttpFoundation\StreamedResponse;
/**
@ -76,6 +78,11 @@ class convertor
*/
protected $db;
/**
* @var Connection
*/
protected $db_doctrine;
/**
* @var install_helper
*/
@ -165,10 +172,11 @@ class convertor
$this->controller_helper->handle_language_select();
$this->cache = $container->get('cache.driver');
$this->config = $container->get('config');
$this->cache = $container->get('cache.driver');
$this->config = $container->get('config');
$this->config_php_file = new \phpbb\config_php_file($this->phpbb_root_path, $this->php_ext);
$this->db = $container->get('dbal.conn.driver');
$this->db = $container->get('dbal.conn.driver');
$this->db_doctrine = $container->get('dbal.conn.doctrine');
$this->config_table = $container->get_parameter('tables.config');
$this->session_keys_table = $container->get_parameter('tables.sessions_keys');
@ -507,11 +515,13 @@ class convertor
/** @var \phpbb\db\driver\driver_interface $src_db */
$src_db = new $src_dbms();
$src_db->sql_connect($src_dbhost, $src_dbuser, htmlspecialchars_decode($src_dbpasswd, ENT_COMPAT), $src_dbname, $src_dbport, false, true);
$src_db_doctrine = connection_factory::get_connection_from_params($src_dbms, $src_dbhost, $src_dbuser, htmlspecialchars_decode($src_dbpasswd, ENT_COMPAT), $src_dbname, $src_dbport);
$same_db = false;
}
else
{
$src_db = $this->db;
$src_db_doctrine = $this->db_doctrine;
$same_db = true;
}
@ -526,7 +536,7 @@ class convertor
$prefixes = array();
$db_tools_factory = new \phpbb\db\tools\factory();
$db_tools = $db_tools_factory->get($src_db);
$db_tools = $db_tools_factory->get($src_db_doctrine);
$tables_existing = $db_tools->sql_list_tables();
$tables_existing = array_map('strtolower', $tables_existing);
foreach ($tables_existing as $table_name)

View file

@ -1876,11 +1876,7 @@ function phpbb_check_username_collisions()
function phpbb_convert_timezone($timezone)
{
global $config, $db, $phpbb_root_path, $phpEx, $table_prefix;
$factory = new \phpbb\db\tools\factory();
$timezone_migration = new \phpbb\db\migration\data\v310\timezone($config, $db, $factory->get($db), $phpbb_root_path, $phpEx, $table_prefix);
return $timezone_migration->convert_phpbb30_timezone($timezone, 0);
return \phpbb\db\migration\data\v310\timezone::convert_phpbb30_timezone($timezone, 0);
}
function phpbb_add_notification_options($user_notify_pm)

View file

@ -4,7 +4,7 @@
* 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)
* @license GNU General Public License, version 2 (GPL-2.0)
*
* For full copyright and license information, please see
* the docs/CREDITS.txt file.
@ -33,8 +33,8 @@ class connection_factory
*
* @return Connection Doctrine DBAL connection.
*
* @throws runtime_exception If the database connection could not be established.
* @throws InvalidArgumentException If the provided driver name is not a valid phpBB database driver.
* @throws runtime_exception If the database connection could not be established.
* @throws InvalidArgumentException If the provided driver name is not a valid phpBB database driver.
*/
public static function get_connection(config_php_file $config): Connection
{
@ -58,17 +58,17 @@ class connection_factory
/**
* Creates a database connection from the specified parameters.
*
* @param string $driver Driver name.
* @param string $host Hostname.
* @param string|null $user Username.
* @param string|null $password Password.
* @param string|null $name Database name.
* @param string|null $port Database port.
* @param string $driver Driver name.
* @param string $host Hostname.
* @param string|null $user Username.
* @param string|null $password Password.
* @param string|null $name Database name.
* @param string|null $port Database port.
*
* @return Connection Doctrine DBAL connection.
*
* @throws runtime_exception If the database connection could not be established.
* @throws InvalidArgumentException If $driver is not a valid phpBB database driver.
* @throws runtime_exception If the database connection could not be established.
* @throws InvalidArgumentException If $driver is not a valid phpBB database driver.
*/
public static function get_connection_from_params(
string $driver,
@ -97,13 +97,16 @@ class connection_factory
try
{
$connection = DriverManager::getConnection($params);
Type::addType(case_insensitive_string::CASE_INSENSITIVE_STRING, case_insensitive_string::class);
if (!Type::hasType(case_insensitive_string::CASE_INSENSITIVE_STRING))
{
Type::addType(case_insensitive_string::CASE_INSENSITIVE_STRING, case_insensitive_string::class);
}
$connection->getDatabasePlatform()->registerDoctrineTypeMapping('varchar_ci', case_insensitive_string::CASE_INSENSITIVE_STRING);
return $connection;
}
catch (Exception $e)
{
throw new runtime_exception('DB_CONNECTION_FAILED');
throw new runtime_exception('DB_CONNECTION_FAILED', [], $e);
}
}

View file

@ -14,6 +14,7 @@
namespace phpbb\db\doctrine;
use InvalidArgumentException;
use phpbb\db\doctrine\oci8\driver as oci8_driver;
/**
* Helper class to generate Doctrine DBAL configuration.
@ -152,9 +153,14 @@ class connection_parameter_factory
'oci8' => [
'charset' => 'UTF8',
'platform' => new oracle_platform(),
'driverClass' => oci8_driver::class,
],
'pdo_pgsql' => [
'charset' => 'UTF8',
'platform' => new postgresql_platform(),
],
'pdo_sqlsrv' => [
'platform' => new sqlsrv_platform(),
],
];

View file

@ -4,7 +4,7 @@
* 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)
* @license GNU General Public License, version 2 (GPL-2.0)
*
* For full copyright and license information, please see
* the docs/CREDITS.txt file.
@ -27,7 +27,7 @@ class table_helper
public static function convert_column_data(array $column_data, string $dbms_layer): array
{
$options = self::resolve_dbms_specific_options($column_data, $dbms_layer);
list($type, $opts) = type_converter::convert($column_data[0]);
list($type, $opts) = type_converter::convert($column_data[0], $dbms_layer);
$options = array_merge($options, $opts);
return [$type, $options];
}
@ -35,8 +35,8 @@ class table_helper
/**
* Resolve DBMS specific options in column data.
*
* @param array $column_data Original column data.
* @param string $dbms_layer DBMS layer name.
* @param array $column_data Original column data.
* @param string $dbms_layer DBMS layer name.
*
* @return array Doctrine column options.
*/
@ -54,12 +54,19 @@ class table_helper
$doctrine_options['default'] = $column_data[1];
$doctrine_options['notnull'] = true;
}
else
{
$doctrine_options['notnull'] = false;
}
$non_string_pattern = '/^[a-z]*(?:int|decimal|bool|timestamp)(?::[0-9]+)?$/';
if ($dbms_layer === 'oracle' && !preg_match($non_string_pattern, strtolower($column_data[0]))
&& array_key_exists('default', $doctrine_options[0]) && $doctrine_options[0]['default'] === '')
if ($dbms_layer === 'oracle'
&& !preg_match($non_string_pattern, strtolower($column_data[0]))
&& array_key_exists('default', $doctrine_options)
&& $doctrine_options['default'] === '')
{
unset($doctrine_options['notnull']);
// Not null is true by default and Oracle does not allow empty strings in not null columns
$doctrine_options['notnull'] = false;
}
if (isset($column_data[2]))
@ -80,8 +87,8 @@ class table_helper
/**
* Returns the DBMS specific default value for a column definition.
*
* @param array $default_options Database specific default value options.
* @param string $dbms_layer Name of the DBMS layer.
* @param array $default_options Database specific default value options.
* @param string $dbms_layer Name of the DBMS layer.
*
* @return mixed Default value for the current DBMS.
*

View file

@ -24,6 +24,7 @@ class type_converter
* @var array
*/
private const TYPE_MAP = [
'INT' => ['integer', []],
'BINT' => ['bigint', []],
'ULINT' => ['integer', ['unsigned' => true]],
'UINT' => ['integer', ['unsigned' => true]],
@ -41,8 +42,8 @@ class type_converter
'MTEXT' => ['text', ['length' => ((1 << 24) - 1)]],
'MTEXT_UNI' => ['text', ['length' => ((1 << 24) - 1)]],
'TIMESTAMP' => ['integer', ['unsigned' => true]],
'DECIMAL' => ['integer', ['precision' => 5, 'scale' => 2]],
'PDECIMAL' => ['integer', ['precision' => 6, 'scale' => 3]],
'DECIMAL' => ['decimal', ['precision' => 5, 'scale' => 2]],
'PDECIMAL' => ['decimal', ['precision' => 6, 'scale' => 3]],
'VCHAR_UNI' => ['string', ['length' => 255]],
'VCHAR_CI' => ['string_ci', ['length' => 255]],
'VARBINARY' => ['binary', ['length' => 255]],
@ -55,7 +56,7 @@ class type_converter
*
* @return array<string, array> Pair of type name and options.
*/
public static function convert(string $type): array
public static function convert(string $type, string $dbms): array
{
if (strpos($type, ':') !== false)
{
@ -63,7 +64,7 @@ class type_converter
return self::mapWithLength($typename, (int) $length);
}
return self::mapType($type);
return self::mapType($type, $dbms);
}
/**
@ -108,13 +109,40 @@ class type_converter
*
* @return array<string, array> Pair of type name and an array of options.
*/
private static function mapType(string $type): array
private static function mapType(string $type, string $dbms): array
{
if (!in_array($type, self::TYPE_MAP, true))
if (!array_key_exists($type, self::TYPE_MAP))
{
throw new \InvalidArgumentException("Database type is undefined.");
}
// Historically, on mssql varbinary fields were stored as varchar.
// For compatibility reasons we have to keep it (because when
// querying the database, mssql does not convert strings to their
// binary representation automatically like the other dbms.
if ($type === 'VARBINARY' && $dbms === 'mssql')
{
return self::TYPE_MAP['VCHAR'];
}
// Historically, on mssql bool fields were stored as integer.
// For compatibility reasons we have to keep it because is
// some queries we are using MIN() to these columns which
// is forbidden by MSSQL for bool (bit) columns.
if ($type === 'BOOL' && $dbms === 'mssql')
{
return self::TYPE_MAP['TINT'];
}
// Historically, on postgres bool fields were stored as integer.
// For compatibility reasons we have to keep it because when
// querying the database, postgres does not convert automatically
// 0 and 1 to their boolean representation like the other dbms.
if ($type === 'BOOL' && $dbms === 'postgresql')
{
return self::TYPE_MAP['TINT'];
}
return self::TYPE_MAP[$type];
}
}

View file

@ -72,7 +72,7 @@ class timezone extends \phpbb\db\migration\migration
foreach ($update_blocks as $timezone => $user_ids)
{
$timezone = explode(':', $timezone);
$converted_timezone = $this->convert_phpbb30_timezone($timezone[0], $timezone[1]);
$converted_timezone = static::convert_phpbb30_timezone($timezone[0], $timezone[1]);
$sql = 'UPDATE ' . $this->table_prefix . "users
SET user_timezone = '" . $this->db->sql_escape($converted_timezone) . "'
@ -88,7 +88,7 @@ class timezone extends \phpbb\db\migration\migration
// Update board default timezone
$sql = 'UPDATE ' . $this->table_prefix . "config
SET config_value = '" . $this->convert_phpbb30_timezone($this->config['board_timezone'], $this->config['board_dst']) . "'
SET config_value = '" . static::convert_phpbb30_timezone($this->config['board_timezone'], $this->config['board_dst']) . "'
WHERE config_name = 'board_timezone'";
$this->sql_query($sql);
}
@ -101,7 +101,7 @@ class timezone extends \phpbb\db\migration\migration
* @param $dst int Users daylight saving time
* @return string Users new php Timezone which is used since 3.1
*/
public function convert_phpbb30_timezone($timezone, $dst)
public static function convert_phpbb30_timezone($timezone, $dst)
{
$offset = (float) $timezone + (int) $dst;

File diff suppressed because it is too large Load diff

View file

@ -13,32 +13,18 @@
namespace phpbb\db\tools;
use Doctrine\DBAL\Connection;
/**
* A factory which serves the suitable tools instance for the given dbal
*/
class factory
{
/**
* @param mixed $db_driver
* @param bool $return_statements
* @return \phpbb\db\tools\tools_interface
* @return tools_interface
*/
public function get($db_driver, $return_statements = false)
public function get(Connection $connection, $return_statements = false)
{
// @todo: only create the doctrine tools object.
if ($db_driver instanceof \phpbb\db\driver\mssql_base)
{
return new \phpbb\db\tools\mssql($db_driver, $return_statements);
}
else if ($db_driver instanceof \phpbb\db\driver\postgres)
{
return new \phpbb\db\tools\postgres($db_driver, $return_statements);
}
else if ($db_driver instanceof \phpbb\db\driver\driver_interface)
{
return new \phpbb\db\tools\tools($db_driver, $return_statements);
}
throw new \InvalidArgumentException('Invalid database driver given');
return new doctrine($connection, $return_statements);
}
}

View file

@ -19,6 +19,6 @@ namespace phpbb\db\tools;
*
* @deprecated 4.0.0-a1
*/
class tools extends doctrine
interface tools extends tools_interface
{
}

View file

@ -1,15 +1,15 @@
<?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.
*
*/
*
* 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\tools;
@ -22,38 +22,41 @@ interface tools_interface
* Handle passed database update array.
* Expected structure...
* Key being one of the following
* drop_tables: Drop tables
* add_tables: Add tables
* change_columns: Column changes (only type, not name)
* add_columns: Add columns to a table
* drop_keys: Dropping keys
* drop_columns: Removing/Dropping columns
* add_primary_keys: adding primary keys
* add_unique_index: adding an unique index
* add_index: adding an index (can be column:index_size if you need to provide size)
* drop_tables: Drop tables
* add_tables: Add tables
* change_columns: Column changes (only type, not name)
* add_columns: Add columns to a table
* drop_keys: Dropping keys
* drop_columns: Removing/Dropping columns
* add_primary_keys: adding primary keys
* add_unique_index: adding an unique index
* add_index: adding an index (can be column:index_size if you need to provide size)
*
* The values are in this format:
* {TABLE NAME} => array(
* {COLUMN NAME} => array({COLUMN TYPE}, {DEFAULT VALUE}, {OPTIONAL VARIABLES}),
* {KEY/INDEX NAME} => array({COLUMN NAMES}),
* )
* {TABLE NAME} => array(
* {COLUMN NAME} => array({COLUMN TYPE}, {DEFAULT VALUE}, {OPTIONAL VARIABLES}),
* {KEY/INDEX NAME} => array({COLUMN NAMES}),
* )
*
*
* @param array $schema_changes
*
* @return bool|string[]
*/
public function perform_schema_changes(array $schema_changes): void;
public function perform_schema_changes(array $schema_changes);
/**
* Gets a list of tables in the database.
*
* @return array Array of table names (all lower case)
* @return array Array of table names (all lower case)
*/
public function sql_list_tables(): array;
/**
* Check if table exists
*
* @param string $table_name The table name to check for
* @param string $table_name The table name to check for
*
* @return bool True if table exists, else false
*/
public function sql_table_exists(string $table_name): bool;
@ -61,68 +64,72 @@ interface tools_interface
/**
* Create SQL Table
*
* @param string $table_name The table name to create
* @param array $table_data Array containing table data.
* @return bool True if the statements have been executed
* @param string $table_name The table name to create
* @param array $table_data Array containing table data.
*
* @return bool|string[] True if the statements have been executed
*/
public function sql_create_table(string $table_name, array $table_data): bool;
public function sql_create_table(string $table_name, array $table_data);
/**
* Drop Table
*
* @param string $table_name The table name to drop
* @return bool True if the statements have been executed
* @param string $table_name The table name to drop
*
* @return bool|string[] True if the statements have been executed
*/
public function sql_table_drop(string $table_name): bool;
public function sql_table_drop(string $table_name);
/**
* Gets a list of columns of a table.
*
* @param string $table_name Table name
* @return array Array of column names (all lower case)
* @param string $table_name Table name
*
* @return array Array of column names (all lower case)
*/
public function sql_list_columns(string $table_name): array;
/**
* Check whether a specified column exist in a table
*
* @param string $table_name Table to check
* @param string $column_name Column to check
* @return bool True if column exists, false otherwise
* @param string $table_name Table to check
* @param string $column_name Column to check
*
* @return bool True if column exists, false otherwise
*/
public function sql_column_exists(string $table_name, string $column_name): bool;
/**
* Add new column
*
* @param string $table_name Table to modify
* @param string $column_name Name of the column to add
* @param array $column_data Column data
* @param string $table_name Table to modify
* @param string $column_name Name of the column to add
* @param array $column_data Column data
*
* @return bool True if the statements have been executed
* @return bool|string[] True if the statements have been executed
*/
public function sql_column_add(string $table_name, string $column_name, array $column_data): bool;
public function sql_column_add(string $table_name, string $column_name, array $column_data);
/**
* Change column type (not name!)
*
* @param string $table_name Table to modify
* @param string $column_name Name of the column to modify
* @param array $column_data Column data
* @param string $table_name Table to modify
* @param string $column_name Name of the column to modify
* @param array $column_data Column data
*
* @return bool True if the statements have been executed
* @return bool|string[] True if the statements have been executed
*/
public function sql_column_change(string $table_name, string $column_name, array $column_data): bool;
public function sql_column_change(string $table_name, string $column_name, array $column_data);
/**
* Drop column
*
* @param string $table_name Table to modify
* @param string $column_name Name of the column to drop
* @param string $table_name Table to modify
* @param string $column_name Name of the column to drop
*
* @return bool True if the statements have been executed
* @return bool|string[] True if the statements have been executed
*/
public function sql_column_remove(string $table_name, string $column_name): bool;
public function sql_column_remove(string $table_name, string $column_name);
/**
* List all of the indices that belong to a table
@ -131,66 +138,73 @@ interface tools_interface
* - UNIQUE indices
* - PRIMARY keys
*
* @param string $table_name Table to check
* @return array Array with index names
* @param string $table_name Table to check
*
* @return array Array with index names
*/
public function sql_list_index(string $table_name): array;
/**
* Check if a specified index exists in table. Does not return PRIMARY KEY and UNIQUE indexes.
*
* @param string $table_name Table to check the index at
* @param string $index_name The index name to check
* @return bool True if index exists, else false
* @param string $table_name Table to check the index at
* @param string $index_name The index name to check
*
* @return bool True if index exists, else false
*/
public function sql_index_exists(string $table_name, string $index_name): bool;
/**
* Add index
*
* @param string $table_name Table to modify
* @param string $index_name Name of the index to create
* @param string|array $column Either a string with a column name, or an array with columns
* @return bool True if the statements have been executed
* @param string $table_name Table to modify
* @param string $index_name Name of the index to create
* @param string|array $column Either a string with a column name, or an array with columns
*
* @return bool|string[] True if the statements have been executed
*/
public function sql_create_index(string $table_name, string $index_name, $column): bool;
public function sql_create_index(string $table_name, string $index_name, $column);
/**
* Drop Index
*
* @param string $table_name Table to modify
* @param string $index_name Name of the index to delete
* @return bool True if the statements have been executed
* @param string $table_name Table to modify
* @param string $index_name Name of the index to delete
*
* @return bool|string[] True if the statements have been executed
*/
public function sql_index_drop(string $table_name, string $index_name): bool;
public function sql_index_drop(string $table_name, string $index_name);
/**
* Check if a specified index exists in table.
*
* NOTE: Does not return normal and PRIMARY KEY indexes
*
* @param string $table_name Table to check the index at
* @param string $index_name The index name to check
* @return bool True if index exists, else false
* @param string $table_name Table to check the index at
* @param string $index_name The index name to check
*
* @return bool|string[] True if index exists, else false
*/
public function sql_unique_index_exists(string $table_name, string $index_name): bool;
public function sql_unique_index_exists(string $table_name, string $index_name);
/**
* Add unique index
*
* @param string $table_name Table to modify
* @param string $index_name Name of the unique index to create
* @param string|array $column Either a string with a column name, or an array with columns
* @return bool True if the statements have been executed
* @param string $table_name Table to modify
* @param string $index_name Name of the unique index to create
* @param string|array $column Either a string with a column name, or an array with columns
*
* @return bool|string[] True if the statements have been executed
*/
public function sql_create_unique_index(string $table_name, string $index_name, $column): bool;
public function sql_create_unique_index(string $table_name, string $index_name, $column);
/**
* Add primary key
*
* @param string $table_name Table to modify
* @param string|array $column Either a string with a column name, or an array with columns
* @return bool True if the statements have been executed
* @param string $table_name Table to modify
* @param string|array $column Either a string with a column name, or an array with columns
*
* @return bool|string[] True if the statements have been executed
*/
public function sql_create_primary_key(string $table_name, $column): bool;
public function sql_create_primary_key(string $table_name, $column);
}

View file

@ -13,6 +13,7 @@
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;
@ -55,6 +56,11 @@ class container_builder
*/
protected $dbal_connection = null;
/**
* @var \Doctrine\DBAL\Connection
*/
private $dbal_connection_doctrine;
/**
* Indicates whether extensions should be used (default to true).
*
@ -587,8 +593,10 @@ class container_builder
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);
}
}

View file

@ -13,6 +13,7 @@
namespace phpbb\install\helper;
use phpbb\db\doctrine\connection_factory;
use phpbb\install\exception\invalid_dbms_exception;
use phpbb\filesystem\helper as filesystem_helper;
@ -389,8 +390,9 @@ class database
$temp_prefix . 'users',
);
$doctrine_db = connection_factory::get_connection_from_params($dbms, $dbhost, $dbuser, $dbpass, $dbname, $dbport);
$db_tools_factory = new \phpbb\db\tools\factory();
$db_tools = $db_tools_factory->get($db);
$db_tools = $db_tools_factory->get($doctrine_db);
$tables = $db_tools->sql_list_tables();
$tables = array_map('strtolower', $tables);
$table_intersect = array_intersect($tables, $table_ary);

View file

@ -13,6 +13,7 @@
namespace phpbb\install\module\install_database\task;
use phpbb\db\doctrine\connection_factory;
use phpbb\db\driver\driver_interface;
use phpbb\db\tools\tools_interface;
use phpbb\install\helper\config;
@ -83,8 +84,17 @@ class add_tables extends task_base
false
);
$doctrine_db = connection_factory::get_connection_from_params(
$config->get('dbms'),
$config->get('dbhost'),
$config->get('dbuser'),
$config->get('dbpasswd'),
$config->get('dbname'),
$config->get('dbport')
);
$this->config = $config;
$this->db_tools = $factory->get($this->db);
$this->db_tools = $factory->get($doctrine_db);
$this->schema_file_path = $phpbb_root_path . 'store/schema.json';
$this->table_prefix = $this->config->get('table_prefix');
$this->change_prefix = $this->config->get('change_table_prefix', true);

View file

@ -13,6 +13,7 @@
namespace phpbb\install\module\install_database\task;
use phpbb\db\doctrine\connection_factory;
use phpbb\install\exception\resource_limit_reached_exception;
/**
@ -30,6 +31,11 @@ class create_schema_file extends \phpbb\install\task_base
*/
protected $db;
/**
* @var \Doctrine\DBAL\Connection
*/
protected $db_doctrine;
/**
* @var \phpbb\filesystem\filesystem_interface
*/
@ -81,6 +87,15 @@ class create_schema_file extends \phpbb\install\task_base
false
);
$this->db_doctrine = connection_factory::get_connection_from_params(
$config->get('dbms'),
$config->get('dbhost'),
$config->get('dbuser'),
$config->get('dbpasswd'),
$config->get('dbname'),
$config->get('dbport')
);
$this->config = $config;
$this->filesystem = $filesystem;
$this->phpbb_root_path = $phpbb_root_path;
@ -129,7 +144,7 @@ class create_schema_file extends \phpbb\install\task_base
$finder = $finder_factory->get();
$migrator_classes = $finder->core_path('phpbb/db/migration/data/')->get_classes();
$factory = new \phpbb\db\tools\factory();
$db_tools = $factory->get($this->db, true);
$db_tools = $factory->get($this->db_doctrine, 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)