mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-23 10:28:55 +00:00
Merge pull request #6839 from rxu/ticket/17530
[ticket/17530] Use Doctrine driver middleware instead of 'platform' parameter
This commit is contained in:
commit
06b9ca4768
20 changed files with 288 additions and 373 deletions
|
@ -15,6 +15,8 @@ namespace phpbb\db\doctrine;
|
|||
|
||||
use Doctrine\DBAL\Platforms\AbstractPlatform;
|
||||
use Doctrine\DBAL\Types\Type;
|
||||
use phpbb\db\middleware\oracle\platform as oracle_platform;
|
||||
use phpbb\db\middleware\postgresql\platform as postgresql_platform;
|
||||
|
||||
/**
|
||||
* Case-insensitive string type (only supported by Postgres).
|
||||
|
|
|
@ -13,12 +13,17 @@
|
|||
|
||||
namespace phpbb\db\doctrine;
|
||||
|
||||
use Doctrine\DBAL\Configuration;
|
||||
use Doctrine\DBAL\Connection;
|
||||
use Doctrine\DBAL\DriverManager;
|
||||
use Doctrine\DBAL\Exception;
|
||||
use Doctrine\DBAL\Types\Type;
|
||||
use InvalidArgumentException;
|
||||
use phpbb\config_php_file;
|
||||
use phpbb\db\middleware\mysql\middleware as mysql_middleware;
|
||||
use phpbb\db\middleware\oracle\middleware as oracle_middleware;
|
||||
use phpbb\db\middleware\postgresql\middleware as postgresql_middleware;
|
||||
use phpbb\db\middleware\sqlsrv\middleware as sqlsrv_middleware;
|
||||
use phpbb\exception\runtime_exception;
|
||||
|
||||
/**
|
||||
|
@ -94,9 +99,21 @@ class connection_factory
|
|||
$port
|
||||
);
|
||||
|
||||
$middleware = match($driver)
|
||||
{
|
||||
'pdo_mysql', 'mysqli' => [new mysql_middleware()],
|
||||
'pdo_oci', 'oci8' => [new oracle_middleware()],
|
||||
'pdo_pgsql', 'pgsql' => [new postgresql_middleware()],
|
||||
'pdo_sqlsrv', 'sqlsrv' => [new sqlsrv_middleware()],
|
||||
default => [],
|
||||
};
|
||||
|
||||
try
|
||||
{
|
||||
$connection = DriverManager::getConnection($params);
|
||||
$connection_config = new Configuration();
|
||||
$connection_config->setMiddlewares($middleware);
|
||||
|
||||
$connection = DriverManager::getConnection($params, $connection_config);
|
||||
if (!Type::hasType(case_insensitive_string::CASE_INSENSITIVE_STRING))
|
||||
{
|
||||
Type::addType(case_insensitive_string::CASE_INSENSITIVE_STRING, case_insensitive_string::class);
|
||||
|
|
|
@ -13,9 +13,6 @@
|
|||
|
||||
namespace phpbb\db\doctrine;
|
||||
|
||||
use InvalidArgumentException;
|
||||
use phpbb\db\doctrine\oci8\driver as oci8_driver;
|
||||
|
||||
/**
|
||||
* Helper class to generate Doctrine DBAL configuration.
|
||||
*/
|
||||
|
@ -33,7 +30,7 @@ class connection_parameter_factory
|
|||
*
|
||||
* @return array Doctrine DBAL connection parameters.
|
||||
*
|
||||
* @throws InvalidArgumentException If a required parameter is empty or null.
|
||||
* @throws \InvalidArgumentException If a required parameter is empty or null.
|
||||
*/
|
||||
public static function get_configuration(
|
||||
string $driver,
|
||||
|
@ -69,7 +66,7 @@ class connection_parameter_factory
|
|||
*
|
||||
* @return array Doctrine's DBAL configuration for SQLite.
|
||||
*
|
||||
* @throws InvalidArgumentException If a required parameter is empty or null.
|
||||
* @throws \InvalidArgumentException If a required parameter is empty or null.
|
||||
*/
|
||||
private static function build_connection_parameters(
|
||||
array $params,
|
||||
|
@ -88,7 +85,7 @@ class connection_parameter_factory
|
|||
|
||||
if (empty($user) || empty($name))
|
||||
{
|
||||
throw new InvalidArgumentException('Required database parameter is not set.');
|
||||
throw new \InvalidArgumentException('Required database parameter is not set.');
|
||||
}
|
||||
|
||||
$params = array_merge($params, [
|
||||
|
@ -146,37 +143,17 @@ class connection_parameter_factory
|
|||
*/
|
||||
private static function enrich_parameters(array $params) : array
|
||||
{
|
||||
$enrichment_tags = [
|
||||
'pdo_mysql' => [
|
||||
'charset' => 'UTF8',
|
||||
'platform' => new mysql_platform(),
|
||||
],
|
||||
'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(),
|
||||
],
|
||||
];
|
||||
if (in_array($params['driver'], ['mysqli', 'pdo_mysql', 'pgsql', 'pdo_pgsql', 'oci8', 'pdo_oci']))
|
||||
{
|
||||
$params['charset'] = 'UTF8';
|
||||
}
|
||||
|
||||
if ($params['driver'] === 'pdo_mysql' && extension_loaded('pdo_mysql'))
|
||||
{
|
||||
$enrichment_tags['pdo_mysql'][\PDO::MYSQL_ATTR_FOUND_ROWS] = true;
|
||||
$params[\PDO::MYSQL_ATTR_FOUND_ROWS] = true;
|
||||
}
|
||||
|
||||
$driver = $params['driver'];
|
||||
if (!array_key_exists($driver, $enrichment_tags))
|
||||
{
|
||||
return $params;
|
||||
}
|
||||
|
||||
return array_merge($params, $enrichment_tags[$driver]);
|
||||
return $params;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -1,99 +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\doctrine\oci8;
|
||||
|
||||
use Doctrine\DBAL\Driver\Connection as DriverConnection;
|
||||
use Doctrine\DBAL\Driver\Result as DriverResult;
|
||||
use Doctrine\DBAL\Driver\Statement as DriverStatement;
|
||||
use Doctrine\DBAL\ParameterType;
|
||||
|
||||
class connection implements DriverConnection
|
||||
{
|
||||
/**
|
||||
* @var DriverConnection
|
||||
*/
|
||||
private $wrapped;
|
||||
|
||||
/**
|
||||
* @param DriverConnection $wrapped
|
||||
*/
|
||||
public function __construct(DriverConnection $wrapped)
|
||||
{
|
||||
$this->wrapped = $wrapped;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function prepare(string $sql): DriverStatement
|
||||
{
|
||||
return new statement($this->wrapped->prepare($sql));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function query(string $sql): DriverResult
|
||||
{
|
||||
return new result($this->wrapped->query($sql));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function quote($value, $type = ParameterType::STRING)
|
||||
{
|
||||
return $this->wrapped->quote($value, $type);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function exec(string $sql): int
|
||||
{
|
||||
return $this->wrapped->exec($sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function lastInsertId($name = null)
|
||||
{
|
||||
return $this->wrapped->lastInsertId($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function beginTransaction(): bool
|
||||
{
|
||||
return $this->wrapped->beginTransaction();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function commit(): bool
|
||||
{
|
||||
return $this->wrapped->commit();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function rollBack(): bool
|
||||
{
|
||||
return $this->wrapped->rollBack();
|
||||
}
|
||||
}
|
|
@ -1,65 +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\doctrine\oci8;
|
||||
|
||||
use Doctrine\DBAL\Connection as DoctrineConnection;
|
||||
use Doctrine\DBAL\Driver\API\ExceptionConverter;
|
||||
use Doctrine\DBAL\Platforms\AbstractPlatform;
|
||||
use Doctrine\DBAL\Driver as DoctrineDriver;
|
||||
use Doctrine\DBAL\Driver\OCI8\Driver as OCI8Driver;
|
||||
|
||||
class driver implements DoctrineDriver
|
||||
{
|
||||
/**
|
||||
* @var DoctrineDriver
|
||||
*/
|
||||
private $wrapped;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->wrapped = new OCI8Driver();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function connect(array $params)
|
||||
{
|
||||
return new connection($this->wrapped->connect($params));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getDatabasePlatform()
|
||||
{
|
||||
return $this->wrapped->getDatabasePlatform();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getSchemaManager(DoctrineConnection $conn, AbstractPlatform $platform)
|
||||
{
|
||||
return new schema_manager($conn, $platform);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getExceptionConverter(): ExceptionConverter
|
||||
{
|
||||
return $this->wrapped->getExceptionConverter();
|
||||
}
|
||||
}
|
|
@ -1,109 +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\doctrine\oci8;
|
||||
|
||||
use Doctrine\DBAL\Driver\Result as DriverResult;
|
||||
|
||||
class result implements DriverResult
|
||||
{
|
||||
/**
|
||||
* @var DriverResult
|
||||
*/
|
||||
private $wrapped;
|
||||
|
||||
/**
|
||||
* @param DriverResult $wrapped
|
||||
*/
|
||||
public function __construct(DriverResult $wrapped)
|
||||
{
|
||||
$this->wrapped = $wrapped;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function fetchNumeric()
|
||||
{
|
||||
return $this->wrapped->fetchNumeric();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function fetchAssociative()
|
||||
{
|
||||
return array_change_key_case($this->wrapped->fetchAssociative(), CASE_LOWER);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function fetchOne()
|
||||
{
|
||||
return $this->wrapped->fetchOne();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function fetchAllNumeric(): array
|
||||
{
|
||||
return $this->wrapped->fetchAllNumeric();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function fetchAllAssociative(): array
|
||||
{
|
||||
$rows = [];
|
||||
foreach ($this->wrapped->fetchAllAssociative() as $row)
|
||||
{
|
||||
$rows[] = array_change_key_case($row, CASE_LOWER);
|
||||
}
|
||||
return $rows;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function fetchFirstColumn(): array
|
||||
{
|
||||
return $this->wrapped->fetchFirstColumn();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function rowCount(): int
|
||||
{
|
||||
return $this->wrapped->rowCount();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function columnCount(): int
|
||||
{
|
||||
return $this->wrapped->columnCount();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function free(): void
|
||||
{
|
||||
$this->wrapped->free();
|
||||
}
|
||||
}
|
|
@ -1,58 +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\doctrine\oci8;
|
||||
|
||||
use Doctrine\DBAL\Driver\Result as DriverResult;
|
||||
use Doctrine\DBAL\Driver\Statement as DriverStatement;
|
||||
use Doctrine\DBAL\ParameterType;
|
||||
|
||||
class statement implements DriverStatement
|
||||
{
|
||||
/**
|
||||
* @var DriverStatement
|
||||
*/
|
||||
private $wrapped;
|
||||
|
||||
/**
|
||||
* @param DriverStatement $wrapped
|
||||
*/
|
||||
public function __construct(DriverStatement $wrapped)
|
||||
{
|
||||
$this->wrapped = $wrapped;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function bindValue($param, $value, $type = ParameterType::STRING): bool
|
||||
{
|
||||
return $this->wrapped->bindValue($param, $value, $type);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function bindParam($param, &$variable, $type = ParameterType::STRING, $length = null): bool
|
||||
{
|
||||
return $this->wrapped->bindParam($param, $variable, $type, $length);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function execute($params = null): DriverResult
|
||||
{
|
||||
return new result($this->wrapped->execute($params));
|
||||
}
|
||||
}
|
31
phpBB/phpbb/db/middleware/mysql/driver.php
Normal file
31
phpBB/phpbb/db/middleware/mysql/driver.php
Normal file
|
@ -0,0 +1,31 @@
|
|||
<?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\middleware\mysql;
|
||||
|
||||
use Doctrine\DBAL\Driver\Middleware\AbstractDriverMiddleware;
|
||||
|
||||
/**
|
||||
* MySQL Doctrine driver middleware.
|
||||
* Makes use of phpBB's MySQL specific platform.
|
||||
*/
|
||||
class driver extends AbstractDriverMiddleware
|
||||
{
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function createDatabasePlatformForVersion($version)
|
||||
{
|
||||
return new platform();
|
||||
}
|
||||
}
|
29
phpBB/phpbb/db/middleware/mysql/middleware.php
Normal file
29
phpBB/phpbb/db/middleware/mysql/middleware.php
Normal file
|
@ -0,0 +1,29 @@
|
|||
<?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\middleware\mysql;
|
||||
|
||||
use Doctrine\DBAL\Driver;
|
||||
use phpbb\db\middleware\mysql\driver as mysql_driver;
|
||||
|
||||
/**
|
||||
* MySQL Doctrine middleware.
|
||||
* Makes use of phpBB's MySQL specific platform.
|
||||
*/
|
||||
class middleware implements Driver\Middleware
|
||||
{
|
||||
public function wrap(Driver $driver): Driver
|
||||
{
|
||||
return new mysql_driver($driver);
|
||||
}
|
||||
}
|
|
@ -11,7 +11,7 @@
|
|||
*
|
||||
*/
|
||||
|
||||
namespace phpbb\db\doctrine;
|
||||
namespace phpbb\db\middleware\mysql;
|
||||
|
||||
use Doctrine\DBAL\Platforms\AbstractMySQLPlatform;
|
||||
use Doctrine\DBAL\Schema\TableDiff;
|
||||
|
@ -23,7 +23,7 @@ use Doctrine\DBAL\Schema\TableDiff;
|
|||
* If it's indexed as primary key, it should be declared as NOT NULL
|
||||
* because MySQL primary key columns cannot be NULL.
|
||||
*/
|
||||
class mysql_platform extends AbstractMySQLPlatform
|
||||
class platform extends AbstractMySQLPlatform
|
||||
{
|
||||
/**
|
||||
* {@inheritDoc}
|
41
phpBB/phpbb/db/middleware/oracle/driver.php
Normal file
41
phpBB/phpbb/db/middleware/oracle/driver.php
Normal file
|
@ -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\middleware\oracle;
|
||||
|
||||
use Doctrine\DBAL\Connection as DoctrineConnection;
|
||||
use Doctrine\DBAL\Driver\Middleware\AbstractDriverMiddleware;
|
||||
use Doctrine\DBAL\Platforms\AbstractPlatform;
|
||||
|
||||
/**
|
||||
* Oracle Doctrine driver middleware.
|
||||
* Makes use of phpBB's Oracle specific platform.
|
||||
*/
|
||||
class driver extends AbstractDriverMiddleware
|
||||
{
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getSchemaManager(DoctrineConnection $conn, AbstractPlatform $platform)
|
||||
{
|
||||
return new schema_manager($conn, $platform);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function createDatabasePlatformForVersion($version)
|
||||
{
|
||||
return new platform();
|
||||
}
|
||||
}
|
29
phpBB/phpbb/db/middleware/oracle/middleware.php
Normal file
29
phpBB/phpbb/db/middleware/oracle/middleware.php
Normal file
|
@ -0,0 +1,29 @@
|
|||
<?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\middleware\oracle;
|
||||
|
||||
use Doctrine\DBAL\Driver;
|
||||
use phpbb\db\middleware\oracle\driver as oracle_driver;
|
||||
|
||||
/**
|
||||
* Oracle Doctrine middleware.
|
||||
* Makes use of phpBB's Oracle specific platform.
|
||||
*/
|
||||
class middleware implements Driver\Middleware
|
||||
{
|
||||
public function wrap(Driver $driver): Driver
|
||||
{
|
||||
return new oracle_driver($driver);
|
||||
}
|
||||
}
|
|
@ -11,7 +11,7 @@
|
|||
*
|
||||
*/
|
||||
|
||||
namespace phpbb\db\doctrine;
|
||||
namespace phpbb\db\middleware\oracle;
|
||||
|
||||
use Doctrine\DBAL\Platforms\OraclePlatform;
|
||||
use Doctrine\DBAL\Schema\Identifier;
|
||||
|
@ -21,7 +21,7 @@ use Doctrine\DBAL\Schema\Table;
|
|||
/**
|
||||
* Oracle specific schema restrictions for BC.
|
||||
*/
|
||||
class oracle_platform extends OraclePlatform
|
||||
class platform extends OraclePlatform
|
||||
{
|
||||
/**
|
||||
* {@inheritDoc}
|
|
@ -11,7 +11,7 @@
|
|||
*
|
||||
*/
|
||||
|
||||
namespace phpbb\db\doctrine\oci8;
|
||||
namespace phpbb\db\middleware\oracle;
|
||||
|
||||
use Doctrine\DBAL\Platforms\OraclePlatform;
|
||||
use Doctrine\DBAL\Schema\AbstractSchemaManager;
|
31
phpBB/phpbb/db/middleware/postgresql/driver.php
Normal file
31
phpBB/phpbb/db/middleware/postgresql/driver.php
Normal file
|
@ -0,0 +1,31 @@
|
|||
<?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\middleware\postgresql;
|
||||
|
||||
use Doctrine\DBAL\Driver\Middleware\AbstractDriverMiddleware;
|
||||
|
||||
/**
|
||||
* PostgreSQL Doctrine driver middleware.
|
||||
* Makes use of phpBB's PostgreSQL specific platform.
|
||||
*/
|
||||
class driver extends AbstractDriverMiddleware
|
||||
{
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function createDatabasePlatformForVersion($version)
|
||||
{
|
||||
return new platform();
|
||||
}
|
||||
}
|
29
phpBB/phpbb/db/middleware/postgresql/middleware.php
Normal file
29
phpBB/phpbb/db/middleware/postgresql/middleware.php
Normal file
|
@ -0,0 +1,29 @@
|
|||
<?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\middleware\postgresql;
|
||||
|
||||
use Doctrine\DBAL\Driver;
|
||||
use phpbb\db\middleware\postgresql\driver as postgresql_driver;
|
||||
|
||||
/**
|
||||
* PostgreSQL Doctrine middleware.
|
||||
* Makes use of phpBB's PostgreSQL specific platform.
|
||||
*/
|
||||
class middleware implements Driver\Middleware
|
||||
{
|
||||
public function wrap(Driver $driver): Driver
|
||||
{
|
||||
return new postgresql_driver($driver);
|
||||
}
|
||||
}
|
|
@ -11,7 +11,7 @@
|
|||
*
|
||||
*/
|
||||
|
||||
namespace phpbb\db\doctrine;
|
||||
namespace phpbb\db\middleware\postgresql;
|
||||
|
||||
use Doctrine\DBAL\Platforms\AbstractPlatform;
|
||||
use Doctrine\DBAL\Platforms\PostgreSQLPlatform;
|
||||
|
@ -31,7 +31,7 @@ use Doctrine\DBAL\Types\Type;
|
|||
* to stay compatible with the existing DB we have to change its
|
||||
* naming and not ours.
|
||||
*/
|
||||
class postgresql_platform extends PostgreSQLPlatform
|
||||
class platform extends PostgreSQLPlatform
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
31
phpBB/phpbb/db/middleware/sqlsrv/driver.php
Normal file
31
phpBB/phpbb/db/middleware/sqlsrv/driver.php
Normal file
|
@ -0,0 +1,31 @@
|
|||
<?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\middleware\sqlsrv;
|
||||
|
||||
use Doctrine\DBAL\Driver\Middleware\AbstractDriverMiddleware;
|
||||
|
||||
/**
|
||||
* Microsoft SQL server Doctrine driver middleware.
|
||||
* Makes use of phpBB's SQL Server specific platform.
|
||||
*/
|
||||
class driver extends AbstractDriverMiddleware
|
||||
{
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function createDatabasePlatformForVersion($version)
|
||||
{
|
||||
return new platform();
|
||||
}
|
||||
}
|
29
phpBB/phpbb/db/middleware/sqlsrv/middleware.php
Normal file
29
phpBB/phpbb/db/middleware/sqlsrv/middleware.php
Normal file
|
@ -0,0 +1,29 @@
|
|||
<?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\middleware\sqlsrv;
|
||||
|
||||
use Doctrine\DBAL\Driver;
|
||||
use phpbb\db\middleware\sqlsrv\driver as sqlsrv_driver;
|
||||
|
||||
/**
|
||||
* Microsoft SQL server Doctrine middleware.
|
||||
* Makes use of phpBB's SQL Server specific platform.
|
||||
*/
|
||||
class middleware implements Driver\Middleware
|
||||
{
|
||||
public function wrap(Driver $driver): Driver
|
||||
{
|
||||
return new sqlsrv_driver($driver);
|
||||
}
|
||||
}
|
|
@ -11,7 +11,7 @@
|
|||
*
|
||||
*/
|
||||
|
||||
namespace phpbb\db\doctrine;
|
||||
namespace phpbb\db\middleware\sqlsrv;
|
||||
|
||||
use Doctrine\DBAL\Platforms\SQLServerPlatform;
|
||||
use Doctrine\DBAL\Schema\Identifier;
|
||||
|
@ -20,7 +20,7 @@ use Doctrine\DBAL\Schema\TableDiff;
|
|||
/**
|
||||
* SQLServer specific schema restrictions for BC.
|
||||
*/
|
||||
class sqlsrv_platform extends SQLServerPlatform
|
||||
class platform extends SQLServerPlatform
|
||||
{
|
||||
/**
|
||||
* {@inheritDoc}
|
Loading…
Add table
Reference in a new issue