From 55befccc7af409d822e87897f86c5cf4be0cb309 Mon Sep 17 00:00:00 2001 From: Dries Vints Date: Thu, 21 Jan 2021 12:23:20 +0100 Subject: [PATCH 1/5] Bump DBAL to 2.12 --- composer.json | 5 +++-- src/Illuminate/Database/DBAL/TimestampType.php | 2 +- src/Illuminate/Database/MySqlConnection.php | 6 ++---- src/Illuminate/Database/PostgresConnection.php | 6 ++---- src/Illuminate/Database/SQLiteConnection.php | 6 ++---- src/Illuminate/Database/SqlServerConnection.php | 6 ++---- src/Illuminate/Database/composer.json | 5 ++++- 7 files changed, 16 insertions(+), 20 deletions(-) diff --git a/composer.json b/composer.json index 79bea59f041d..2f6f0490d5b5 100644 --- a/composer.json +++ b/composer.json @@ -79,7 +79,7 @@ }, "require-dev": { "aws/aws-sdk-php": "^3.155", - "doctrine/dbal": "^2.6|^3.0", + "doctrine/dbal": "^2.12|^3.0", "filp/whoops": "^2.8", "guzzlehttp/guzzle": "^7.2", "league/flysystem-aws-s3-v3": "^2.0", @@ -96,6 +96,7 @@ "psr/container-implementation": "1.0" }, "conflict": { + "doctrine/dbal": "<2.12", "tightenco/collect": "<5.5.33" }, "autoload": { @@ -132,7 +133,7 @@ "ext-redis": "Required to use the Redis cache and queue drivers (^4.0|^5.0).", "aws/aws-sdk-php": "Required to use the SQS queue driver, DynamoDb failed job storage and SES mail driver (^3.155).", "brianium/paratest": "Required to run tests in parallel (^6.0).", - "doctrine/dbal": "Required to rename columns and drop SQLite columns (^2.6|^3.0).", + "doctrine/dbal": "Required to rename columns and drop SQLite columns (^2.12|^3.0).", "filp/whoops": "Required for friendly error pages in development (^2.8).", "fakerphp/faker": "Required to use the eloquent factory builder (^1.9.1).", "guzzlehttp/guzzle": "Required to use the HTTP Client, Mailgun mail driver and the ping methods on schedules (^7.2).", diff --git a/src/Illuminate/Database/DBAL/TimestampType.php b/src/Illuminate/Database/DBAL/TimestampType.php index 0ab733cfe520..8132b03ffb5d 100644 --- a/src/Illuminate/Database/DBAL/TimestampType.php +++ b/src/Illuminate/Database/DBAL/TimestampType.php @@ -2,7 +2,7 @@ namespace Illuminate\Database\DBAL; -use Doctrine\DBAL\DBALException; +use Doctrine\DBAL\Exception as DBALException; use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Types\Type; diff --git a/src/Illuminate/Database/MySqlConnection.php b/src/Illuminate/Database/MySqlConnection.php index 9760358cf5f4..91f01a030099 100755 --- a/src/Illuminate/Database/MySqlConnection.php +++ b/src/Illuminate/Database/MySqlConnection.php @@ -2,8 +2,6 @@ namespace Illuminate\Database; -use Doctrine\DBAL\Driver\PDOMySql\Driver as DoctrineDriver; -use Doctrine\DBAL\Version; use Illuminate\Database\PDO\MySqlDriver; use Illuminate\Database\Query\Grammars\MySqlGrammar as QueryGrammar; use Illuminate\Database\Query\Processors\MySqlProcessor; @@ -84,10 +82,10 @@ protected function getDefaultPostProcessor() /** * Get the Doctrine DBAL driver. * - * @return \Doctrine\DBAL\Driver\PDOMySql\Driver|\Illuminate\Database\PDO\MySqlDriver + * @return \Illuminate\Database\PDO\MySqlDriver */ protected function getDoctrineDriver() { - return class_exists(Version::class) ? new DoctrineDriver : new MySqlDriver; + return new MySqlDriver; } } diff --git a/src/Illuminate/Database/PostgresConnection.php b/src/Illuminate/Database/PostgresConnection.php index 009a02b37def..1fc77439b87f 100755 --- a/src/Illuminate/Database/PostgresConnection.php +++ b/src/Illuminate/Database/PostgresConnection.php @@ -2,8 +2,6 @@ namespace Illuminate\Database; -use Doctrine\DBAL\Driver\PDOPgSql\Driver as DoctrineDriver; -use Doctrine\DBAL\Version; use Illuminate\Database\PDO\PostgresDriver; use Illuminate\Database\Query\Grammars\PostgresGrammar as QueryGrammar; use Illuminate\Database\Query\Processors\PostgresProcessor; @@ -99,10 +97,10 @@ protected function getDefaultPostProcessor() /** * Get the Doctrine DBAL driver. * - * @return \Doctrine\DBAL\Driver\PDOPgSql\Driver|\Illuminate\Database\PDO\PostgresDriver + * @return \Illuminate\Database\PDO\PostgresDriver */ protected function getDoctrineDriver() { - return class_exists(Version::class) ? new DoctrineDriver : new PostgresDriver; + return new PostgresDriver; } } diff --git a/src/Illuminate/Database/SQLiteConnection.php b/src/Illuminate/Database/SQLiteConnection.php index 38116877c3ca..59b5edb210b2 100755 --- a/src/Illuminate/Database/SQLiteConnection.php +++ b/src/Illuminate/Database/SQLiteConnection.php @@ -2,8 +2,6 @@ namespace Illuminate\Database; -use Doctrine\DBAL\Driver\PDOSqlite\Driver as DoctrineDriver; -use Doctrine\DBAL\Version; use Illuminate\Database\PDO\SQLiteDriver; use Illuminate\Database\Query\Grammars\SQLiteGrammar as QueryGrammar; use Illuminate\Database\Query\Processors\SQLiteProcessor; @@ -98,11 +96,11 @@ protected function getDefaultPostProcessor() /** * Get the Doctrine DBAL driver. * - * @return \Doctrine\DBAL\Driver\PDOSqlite\Driver|\Illuminate\Database\PDO\SQLiteDriver + * @return \Illuminate\Database\PDO\SQLiteDriver */ protected function getDoctrineDriver() { - return class_exists(Version::class) ? new DoctrineDriver : new SQLiteDriver; + return new SQLiteDriver; } /** diff --git a/src/Illuminate/Database/SqlServerConnection.php b/src/Illuminate/Database/SqlServerConnection.php index b0b8490d062a..f93c499cb6a7 100755 --- a/src/Illuminate/Database/SqlServerConnection.php +++ b/src/Illuminate/Database/SqlServerConnection.php @@ -3,8 +3,6 @@ namespace Illuminate\Database; use Closure; -use Doctrine\DBAL\Driver\PDOSqlsrv\Driver as DoctrineDriver; -use Doctrine\DBAL\Version; use Illuminate\Database\PDO\SqlServerDriver; use Illuminate\Database\Query\Grammars\SqlServerGrammar as QueryGrammar; use Illuminate\Database\Query\Processors\SqlServerProcessor; @@ -116,10 +114,10 @@ protected function getDefaultPostProcessor() /** * Get the Doctrine DBAL driver. * - * @return \Doctrine\DBAL\Driver\PDOSqlsrv\Driver|\Illuminate\Database\PDO\SqlServerDriver + * @return \Illuminate\Database\PDO\SqlServerDriver */ protected function getDoctrineDriver() { - return class_exists(Version::class) ? new DoctrineDriver : new SqlServerDriver; + return new SqlServerDriver; } } diff --git a/src/Illuminate/Database/composer.json b/src/Illuminate/Database/composer.json index 43c24ef2c3a4..1fc5490c3b56 100644 --- a/src/Illuminate/Database/composer.json +++ b/src/Illuminate/Database/composer.json @@ -24,6 +24,9 @@ "illuminate/support": "^9.0", "symfony/console": "^5.2" }, + "conflict": { + "doctrine/dbal": "<2.12" + }, "autoload": { "psr-4": { "Illuminate\\Database\\": "" @@ -35,7 +38,7 @@ } }, "suggest": { - "doctrine/dbal": "Required to rename columns and drop SQLite columns (^2.6|^3.0).", + "doctrine/dbal": "Required to rename columns and drop SQLite columns (^2.12|^3.0).", "fakerphp/faker": "Required to use the eloquent factory builder (^1.9.1).", "illuminate/console": "Required to use the database commands (^9.0).", "illuminate/events": "Required to use the observers with Eloquent (^9.0).", From c478b267502d94e48ad86a271857128b98a62936 Mon Sep 17 00:00:00 2001 From: Dries Vints Date: Thu, 21 Jan 2021 12:39:43 +0100 Subject: [PATCH 2/5] Fix invalid signatures --- src/Illuminate/Database/Connection.php | 2 +- .../Database/PDO/Concerns/ConnectsToDatabase.php | 2 +- src/Illuminate/Database/PDO/MySqlDriver.php | 12 ++++++++++++ src/Illuminate/Database/PDO/PostgresDriver.php | 12 ++++++++++++ src/Illuminate/Database/PDO/SQLiteDriver.php | 12 ++++++++++++ src/Illuminate/Database/PDO/SqlServerDriver.php | 14 +++++++++++++- 6 files changed, 51 insertions(+), 3 deletions(-) diff --git a/src/Illuminate/Database/Connection.php b/src/Illuminate/Database/Connection.php index b4fa6d4c3a0d..fee34f251808 100755 --- a/src/Illuminate/Database/Connection.php +++ b/src/Illuminate/Database/Connection.php @@ -920,7 +920,7 @@ public function getDoctrineConnection() $this->doctrineConnection = new DoctrineConnection(array_filter([ 'pdo' => $this->getPdo(), 'dbname' => $this->getDatabaseName(), - 'driver' => method_exists($driver, 'getName') ? $driver->getName() : null, + 'driver' => $driver->getName(), 'serverVersion' => $this->getConfig('server_version'), ]), $driver); } diff --git a/src/Illuminate/Database/PDO/Concerns/ConnectsToDatabase.php b/src/Illuminate/Database/PDO/Concerns/ConnectsToDatabase.php index 637c62ce1f5d..8b8a50e386a0 100644 --- a/src/Illuminate/Database/PDO/Concerns/ConnectsToDatabase.php +++ b/src/Illuminate/Database/PDO/Concerns/ConnectsToDatabase.php @@ -13,7 +13,7 @@ trait ConnectsToDatabase * @param array $params * @return \Illuminate\Database\PDO\Connection */ - public function connect(array $params) + public function connect(array $params, $username = null, $password = null, array $driverOptions = []) { if (! isset($params['pdo']) || ! $params['pdo'] instanceof PDO) { throw new \InvalidArgumentException('Laravel requires the "pdo" property to be set and be a PDO instance.'); diff --git a/src/Illuminate/Database/PDO/MySqlDriver.php b/src/Illuminate/Database/PDO/MySqlDriver.php index 5f68c6fab5a4..d1673e04c9e5 100644 --- a/src/Illuminate/Database/PDO/MySqlDriver.php +++ b/src/Illuminate/Database/PDO/MySqlDriver.php @@ -8,4 +8,16 @@ class MySqlDriver extends AbstractMySQLDriver { use ConnectsToDatabase; + + /** + * Gets the name of the driver. + * + * @deprecated + * + * @return string The name of the driver. + */ + public function getName() + { + return 'pdo_mysql'; + } } diff --git a/src/Illuminate/Database/PDO/PostgresDriver.php b/src/Illuminate/Database/PDO/PostgresDriver.php index eb29c969de58..a397ea711e47 100644 --- a/src/Illuminate/Database/PDO/PostgresDriver.php +++ b/src/Illuminate/Database/PDO/PostgresDriver.php @@ -8,4 +8,16 @@ class PostgresDriver extends AbstractPostgreSQLDriver { use ConnectsToDatabase; + + /** + * Gets the name of the driver. + * + * @deprecated + * + * @return string The name of the driver. + */ + public function getName() + { + return 'pdo_pgsql'; + } } diff --git a/src/Illuminate/Database/PDO/SQLiteDriver.php b/src/Illuminate/Database/PDO/SQLiteDriver.php index 2dac06db8be0..41ccfab19243 100644 --- a/src/Illuminate/Database/PDO/SQLiteDriver.php +++ b/src/Illuminate/Database/PDO/SQLiteDriver.php @@ -8,4 +8,16 @@ class SQLiteDriver extends AbstractSQLiteDriver { use ConnectsToDatabase; + + /** + * Gets the name of the driver. + * + * @deprecated + * + * @return string The name of the driver. + */ + public function getName() + { + return 'pdo_sqlite'; + } } diff --git a/src/Illuminate/Database/PDO/SqlServerDriver.php b/src/Illuminate/Database/PDO/SqlServerDriver.php index bbb3bbd32397..9ef4aba72a6c 100644 --- a/src/Illuminate/Database/PDO/SqlServerDriver.php +++ b/src/Illuminate/Database/PDO/SqlServerDriver.php @@ -6,10 +6,22 @@ class SqlServerDriver extends AbstractSQLServerDriver { - public function connect(array $params) + public function connect(array $params, $username = null, $password = null, array $driverOptions = []) { return new SqlServerConnection( new Connection($params['pdo']) ); } + + /** + * Gets the name of the driver. + * + * @deprecated + * + * @return string The name of the driver. + */ + public function getName() + { + return 'pdo_sqlsrv'; + } } From 36d80b79014f0f305001aa6f736aa7ffb60bbef7 Mon Sep 17 00:00:00 2001 From: Dries Vints Date: Thu, 21 Jan 2021 12:42:52 +0100 Subject: [PATCH 3/5] Remove conflict --- composer.json | 1 - src/Illuminate/Database/composer.json | 3 --- 2 files changed, 4 deletions(-) diff --git a/composer.json b/composer.json index 2f6f0490d5b5..f249ceab7c20 100644 --- a/composer.json +++ b/composer.json @@ -96,7 +96,6 @@ "psr/container-implementation": "1.0" }, "conflict": { - "doctrine/dbal": "<2.12", "tightenco/collect": "<5.5.33" }, "autoload": { diff --git a/src/Illuminate/Database/composer.json b/src/Illuminate/Database/composer.json index 1fc5490c3b56..43fd5410ef8e 100644 --- a/src/Illuminate/Database/composer.json +++ b/src/Illuminate/Database/composer.json @@ -24,9 +24,6 @@ "illuminate/support": "^9.0", "symfony/console": "^5.2" }, - "conflict": { - "doctrine/dbal": "<2.12" - }, "autoload": { "psr-4": { "Illuminate\\Database\\": "" From 3793a338c162d83d5d2c7de0f6aaf8b36b204536 Mon Sep 17 00:00:00 2001 From: Dries Vints Date: Thu, 21 Jan 2021 14:55:35 +0100 Subject: [PATCH 4/5] inheritdoc --- src/Illuminate/Database/PDO/MySqlDriver.php | 6 +----- src/Illuminate/Database/PDO/PostgresDriver.php | 6 +----- src/Illuminate/Database/PDO/SQLiteDriver.php | 6 +----- src/Illuminate/Database/PDO/SqlServerDriver.php | 6 +----- 4 files changed, 4 insertions(+), 20 deletions(-) diff --git a/src/Illuminate/Database/PDO/MySqlDriver.php b/src/Illuminate/Database/PDO/MySqlDriver.php index d1673e04c9e5..54ac37536189 100644 --- a/src/Illuminate/Database/PDO/MySqlDriver.php +++ b/src/Illuminate/Database/PDO/MySqlDriver.php @@ -10,11 +10,7 @@ class MySqlDriver extends AbstractMySQLDriver use ConnectsToDatabase; /** - * Gets the name of the driver. - * - * @deprecated - * - * @return string The name of the driver. + * {@inheritdoc} */ public function getName() { diff --git a/src/Illuminate/Database/PDO/PostgresDriver.php b/src/Illuminate/Database/PDO/PostgresDriver.php index a397ea711e47..0d9561107cc9 100644 --- a/src/Illuminate/Database/PDO/PostgresDriver.php +++ b/src/Illuminate/Database/PDO/PostgresDriver.php @@ -10,11 +10,7 @@ class PostgresDriver extends AbstractPostgreSQLDriver use ConnectsToDatabase; /** - * Gets the name of the driver. - * - * @deprecated - * - * @return string The name of the driver. + * {@inheritdoc} */ public function getName() { diff --git a/src/Illuminate/Database/PDO/SQLiteDriver.php b/src/Illuminate/Database/PDO/SQLiteDriver.php index 41ccfab19243..f50da08e7d15 100644 --- a/src/Illuminate/Database/PDO/SQLiteDriver.php +++ b/src/Illuminate/Database/PDO/SQLiteDriver.php @@ -10,11 +10,7 @@ class SQLiteDriver extends AbstractSQLiteDriver use ConnectsToDatabase; /** - * Gets the name of the driver. - * - * @deprecated - * - * @return string The name of the driver. + * {@inheritdoc} */ public function getName() { diff --git a/src/Illuminate/Database/PDO/SqlServerDriver.php b/src/Illuminate/Database/PDO/SqlServerDriver.php index 9ef4aba72a6c..7370751caf28 100644 --- a/src/Illuminate/Database/PDO/SqlServerDriver.php +++ b/src/Illuminate/Database/PDO/SqlServerDriver.php @@ -14,11 +14,7 @@ public function connect(array $params, $username = null, $password = null, array } /** - * Gets the name of the driver. - * - * @deprecated - * - * @return string The name of the driver. + * {@inheritdoc} */ public function getName() { From 0ad8e63aebe7b5e5df9fd7872b16de8213fbf72a Mon Sep 17 00:00:00 2001 From: Dries Vints Date: Thu, 21 Jan 2021 16:38:54 +0100 Subject: [PATCH 5/5] DocBlocks --- .../Database/PDO/Concerns/ConnectsToDatabase.php | 5 ++++- src/Illuminate/Database/PDO/SqlServerDriver.php | 9 +++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/Illuminate/Database/PDO/Concerns/ConnectsToDatabase.php b/src/Illuminate/Database/PDO/Concerns/ConnectsToDatabase.php index 8b8a50e386a0..0529ca8eb600 100644 --- a/src/Illuminate/Database/PDO/Concerns/ConnectsToDatabase.php +++ b/src/Illuminate/Database/PDO/Concerns/ConnectsToDatabase.php @@ -10,7 +10,10 @@ trait ConnectsToDatabase /** * Create a new database connection. * - * @param array $params + * @param mixed[] $params + * @param string|null $username + * @param string|null $password + * @param mixed[] $driverOptions * @return \Illuminate\Database\PDO\Connection */ public function connect(array $params, $username = null, $password = null, array $driverOptions = []) diff --git a/src/Illuminate/Database/PDO/SqlServerDriver.php b/src/Illuminate/Database/PDO/SqlServerDriver.php index 7370751caf28..d1f2ae5b2ab0 100644 --- a/src/Illuminate/Database/PDO/SqlServerDriver.php +++ b/src/Illuminate/Database/PDO/SqlServerDriver.php @@ -6,6 +6,15 @@ class SqlServerDriver extends AbstractSQLServerDriver { + /** + * Create a new database connection. + * + * @param mixed[] $params + * @param string|null $username + * @param string|null $password + * @param mixed[] $driverOptions + * @return \Illuminate\Database\PDO\Connection + */ public function connect(array $params, $username = null, $password = null, array $driverOptions = []) { return new SqlServerConnection(