Skip to content

Commit

Permalink
Error out if incompatible DBAL version is detected
Browse files Browse the repository at this point in the history
doctrine/dbal is an optional dependency of laravel/framework, and v3 of
the DBAL has been released recently, but obviously, Laravel 6 was never
meant to be compatible with that version.
Users still using Laravel 6 and updating their dependencies get confused
and file invalid reports on the DBAL, see for instance
doctrine/dbal#4439
or
doctrine/dbal#4757

Fixes #24271
  • Loading branch information
greg0ire committed Aug 25, 2021
1 parent e18f414 commit 55a5da5
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/Illuminate/Database/MySqlConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Illuminate\Database\Query\Processors\MySqlProcessor;
use Illuminate\Database\Schema\Grammars\MySqlGrammar as SchemaGrammar;
use Illuminate\Database\Schema\MySqlBuilder;
use LogicException;

class MySqlConnection extends Connection
{
Expand Down Expand Up @@ -61,6 +62,12 @@ protected function getDefaultPostProcessor()
*/
protected function getDoctrineDriver()
{
if (! class_exists(DoctrineDriver::class)) {
throw new LogicException(
'Laravel v6 is only compatible with doctrine/dbal 2, in order to use this feature you must require the package "doctrine/dbal:^2.6".'
);
}

return new DoctrineDriver;
}
}
7 changes: 7 additions & 0 deletions src/Illuminate/Database/PostgresConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Illuminate\Database\Query\Processors\PostgresProcessor;
use Illuminate\Database\Schema\Grammars\PostgresGrammar as SchemaGrammar;
use Illuminate\Database\Schema\PostgresBuilder;
use LogicException;

class PostgresConnection extends Connection
{
Expand Down Expand Up @@ -61,6 +62,12 @@ protected function getDefaultPostProcessor()
*/
protected function getDoctrineDriver()
{
if (! class_exists(DoctrineDriver::class)) {
throw new LogicException(
'Laravel v6 is only compatible with doctrine/dbal 2, in order to use this feature you must require the package "doctrine/dbal:^2.6".'
);
}

return new DoctrineDriver;
}
}
7 changes: 7 additions & 0 deletions src/Illuminate/Database/SQLiteConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Illuminate\Database\Query\Processors\SQLiteProcessor;
use Illuminate\Database\Schema\Grammars\SQLiteGrammar as SchemaGrammar;
use Illuminate\Database\Schema\SQLiteBuilder;
use LogicException;

class SQLiteConnection extends Connection
{
Expand Down Expand Up @@ -85,6 +86,12 @@ protected function getDefaultPostProcessor()
*/
protected function getDoctrineDriver()
{
if (! class_exists(DoctrineDriver::class)) {
throw new LogicException(
'Laravel v6 is only compatible with doctrine/dbal 2, in order to use this feature you must require the package "doctrine/dbal:^2.6".'
);
}

return new DoctrineDriver;
}

Expand Down
7 changes: 7 additions & 0 deletions src/Illuminate/Database/SqlServerConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Illuminate\Database\Query\Processors\SqlServerProcessor;
use Illuminate\Database\Schema\Grammars\SqlServerGrammar as SchemaGrammar;
use Illuminate\Database\Schema\SqlServerBuilder;
use LogicException;
use Throwable;

class SqlServerConnection extends Connection
Expand Down Expand Up @@ -108,6 +109,12 @@ protected function getDefaultPostProcessor()
*/
protected function getDoctrineDriver()
{
if (! class_exists(DoctrineDriver::class)) {
throw new LogicException(
'Laravel v6 is only compatible with doctrine/dbal 2, in order to use this feature you must require the package "doctrine/dbal:^2.6".'
);
}

return new DoctrineDriver;
}
}

0 comments on commit 55a5da5

Please sign in to comment.