Skip to content

Commit 1fca1c1

Browse files
authored
Error out if incompatible DBAL version is detected (#38543)
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
1 parent e18f414 commit 1fca1c1

File tree

4 files changed

+28
-0
lines changed

4 files changed

+28
-0
lines changed

src/Illuminate/Database/MySqlConnection.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Illuminate\Database\Query\Processors\MySqlProcessor;
88
use Illuminate\Database\Schema\Grammars\MySqlGrammar as SchemaGrammar;
99
use Illuminate\Database\Schema\MySqlBuilder;
10+
use LogicException;
1011

1112
class MySqlConnection extends Connection
1213
{
@@ -61,6 +62,12 @@ protected function getDefaultPostProcessor()
6162
*/
6263
protected function getDoctrineDriver()
6364
{
65+
if (! class_exists(DoctrineDriver::class)) {
66+
throw new LogicException(
67+
'Laravel v6 is only compatible with doctrine/dbal 2, in order to use this feature you must require the package "doctrine/dbal:^2.6".'
68+
);
69+
}
70+
6471
return new DoctrineDriver;
6572
}
6673
}

src/Illuminate/Database/PostgresConnection.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Illuminate\Database\Query\Processors\PostgresProcessor;
88
use Illuminate\Database\Schema\Grammars\PostgresGrammar as SchemaGrammar;
99
use Illuminate\Database\Schema\PostgresBuilder;
10+
use LogicException;
1011

1112
class PostgresConnection extends Connection
1213
{
@@ -61,6 +62,12 @@ protected function getDefaultPostProcessor()
6162
*/
6263
protected function getDoctrineDriver()
6364
{
65+
if (! class_exists(DoctrineDriver::class)) {
66+
throw new LogicException(
67+
'Laravel v6 is only compatible with doctrine/dbal 2, in order to use this feature you must require the package "doctrine/dbal:^2.6".'
68+
);
69+
}
70+
6471
return new DoctrineDriver;
6572
}
6673
}

src/Illuminate/Database/SQLiteConnection.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Illuminate\Database\Query\Processors\SQLiteProcessor;
88
use Illuminate\Database\Schema\Grammars\SQLiteGrammar as SchemaGrammar;
99
use Illuminate\Database\Schema\SQLiteBuilder;
10+
use LogicException;
1011

1112
class SQLiteConnection extends Connection
1213
{
@@ -85,6 +86,12 @@ protected function getDefaultPostProcessor()
8586
*/
8687
protected function getDoctrineDriver()
8788
{
89+
if (! class_exists(DoctrineDriver::class)) {
90+
throw new LogicException(
91+
'Laravel v6 is only compatible with doctrine/dbal 2, in order to use this feature you must require the package "doctrine/dbal:^2.6".'
92+
);
93+
}
94+
8895
return new DoctrineDriver;
8996
}
9097

src/Illuminate/Database/SqlServerConnection.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use Illuminate\Database\Query\Processors\SqlServerProcessor;
1010
use Illuminate\Database\Schema\Grammars\SqlServerGrammar as SchemaGrammar;
1111
use Illuminate\Database\Schema\SqlServerBuilder;
12+
use LogicException;
1213
use Throwable;
1314

1415
class SqlServerConnection extends Connection
@@ -108,6 +109,12 @@ protected function getDefaultPostProcessor()
108109
*/
109110
protected function getDoctrineDriver()
110111
{
112+
if (! class_exists(DoctrineDriver::class)) {
113+
throw new LogicException(
114+
'Laravel v6 is only compatible with doctrine/dbal 2, in order to use this feature you must require the package "doctrine/dbal:^2.6".'
115+
);
116+
}
117+
111118
return new DoctrineDriver;
112119
}
113120
}

0 commit comments

Comments
 (0)