Skip to content

Merge 4.3.x into 5.0.x #7007

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Jun 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ jobs:
- "10.6" # LTS (Jul 2026) We have code specific to 10.6.0-10.10.0
- "10.11" # LTS (Feb 2028) We have code specific to ^10.10
- "11.4" # LTS (May 2029)
- "11.8" # LTS (Jun 2028)
extension:
- "mysqli"
- "pdo_mysql"
Expand Down Expand Up @@ -170,7 +171,7 @@ jobs:
- "8.4"
mysql-version:
- "8.0"
- "9.1"
- "9.3"
extension:
- "mysqli"
- "pdo_mysql"
Expand Down
4 changes: 4 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,10 @@ all drivers and middleware.

# Upgrade to 4.3

## Deprecated support for MariaDB 10.5

* Upgrade to MariaDB 10.6 or later.

## Deprecated `Column` methods

The following `Column` methods have been deprecated:
Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@
"doctrine/coding-standard": "13.0.0",
"fig/log-test": "^1",
"jetbrains/phpstorm-stubs": "2023.2",
"phpstan/phpstan": "2.1.1",
"phpstan/phpstan": "2.1.17",
"phpstan/phpstan-phpunit": "2.0.6",
"phpstan/phpstan-strict-rules": "^2",
"phpunit/phpunit": "11.5.15",
"phpunit/phpunit": "11.5.23",
"slevomat/coding-standard": "8.16.2",
"squizlabs/php_codesniffer": "3.12.0",
"squizlabs/php_codesniffer": "3.13.1",
"symfony/cache": "^6.3.8|^7.0",
"symfony/console": "^5.4|^6.3|^7.0"
},
Expand Down
7 changes: 7 additions & 0 deletions src/Driver/AbstractMySQLDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Doctrine\DBAL\Platforms\MariaDBPlatform;
use Doctrine\DBAL\Platforms\MySQLPlatform;
use Doctrine\DBAL\ServerVersionProvider;
use Doctrine\Deprecations\Deprecation;

use function preg_match;
use function stripos;
Expand Down Expand Up @@ -42,6 +43,12 @@ public function getDatabasePlatform(ServerVersionProvider $versionProvider): Abs
return new MariaDB1060Platform();
}

Deprecation::trigger(
'doctrine/dbal',
'https://github.com/doctrine/dbal/pull/6343',
'Support for MariaDB < 10.6.0 is deprecated and will be removed in DBAL 5',
);

return new MariaDBPlatform();
}

Expand Down
1 change: 1 addition & 0 deletions src/Driver/PgSQL/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public function __construct(private PgSqlConnection $connection)

public function __destruct()
{
// @phpstan-ignore isset.initializedProperty
if (! isset($this->connection)) {
return;
}
Expand Down
10 changes: 10 additions & 0 deletions src/Driver/PgSQL/Driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use function func_get_args;
use function implode;
use function pg_connect;
use function preg_match;
use function restore_error_handler;
use function set_error_handler;
use function sprintf;
Expand Down Expand Up @@ -66,9 +67,18 @@ private function constructConnectionString(
#[SensitiveParameter]
array $params,
): string {
// pg_connect used by Doctrine DBAL does not support [...] notation,
// but requires the host address in plain form like `aa:bb:99...`
$matches = [];
if (isset($params['host']) && preg_match('/^\[(.+)\]$/', $params['host'], $matches) === 1) {
$params['hostaddr'] = $matches[1];
unset($params['host']);
}

$components = array_filter(
[
'host' => $params['host'] ?? null,
'hostaddr' => $params['hostaddr'] ?? null,
'port' => $params['port'] ?? null,
'dbname' => $params['dbname'] ?? 'postgres',
'user' => $params['user'] ?? null,
Expand Down
1 change: 1 addition & 0 deletions src/Driver/PgSQL/Statement.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public function __construct(

public function __destruct()
{
// @phpstan-ignore isset.initializedProperty
if (! isset($this->connection)) {
return;
}
Expand Down
2 changes: 2 additions & 0 deletions src/Platforms/MariaDB1060Platform.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

/**
* Provides the behavior, features and SQL dialect of the MariaDB 10.6 database platform.
*
* @deprecated This class will be removed once support for MariaDB 10.5 is dropped.
*/
class MariaDB1060Platform extends MariaDBPlatform
{
Expand Down
20 changes: 12 additions & 8 deletions src/Schema/TableEditor.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,21 @@ final class TableEditor
/** @internal Use {@link Table::editor()} or {@link Table::edit()} to create an instance */
public function __construct()
{
// @phpstan-ignore assign.propertyType (PHPStan doesn't infer the element type)
$this->columns = new UnqualifiedNamedObjectSet();
/** @var UnqualifiedNamedObjectSet<Column> $columns */
$columns = new UnqualifiedNamedObjectSet();
$this->columns = $columns;
Comment on lines +46 to +48
Copy link
Member

@morozov morozov Jun 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we want to complicate our code instead of just suppressing a false positive error? Never mind, it's already implemented in #7005, we're just merging this up.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After the latest PHPStan update, suppressing the error did not work anymore. You can revert d2b297e and see for yourself. I seems as if PHPStan now prefers the assignment in the constructor over the property's doc block. 😓


// @phpstan-ignore assign.propertyType
$this->indexes = new UnqualifiedNamedObjectSet();
/** @var UnqualifiedNamedObjectSet<Index> $indexes */
$indexes = new UnqualifiedNamedObjectSet();
$this->indexes = $indexes;

// @phpstan-ignore assign.propertyType
$this->uniqueConstraints = new OptionallyUnqualifiedNamedObjectSet();
/** @var OptionallyUnqualifiedNamedObjectSet<UniqueConstraint> $uniqueConstraints */
$uniqueConstraints = new OptionallyUnqualifiedNamedObjectSet();
$this->uniqueConstraints = $uniqueConstraints;

// @phpstan-ignore assign.propertyType
$this->foreignKeyConstraints = new OptionallyUnqualifiedNamedObjectSet();
/** @var OptionallyUnqualifiedNamedObjectSet<ForeignKeyConstraint> $foreignKeyConstraints */
$foreignKeyConstraints = new OptionallyUnqualifiedNamedObjectSet();
$this->foreignKeyConstraints = $foreignKeyConstraints;
}

public function setName(OptionallyQualifiedName $name): self
Expand Down
49 changes: 49 additions & 0 deletions tests/Driver/PgSQL/DriverTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php

declare(strict_types=1);

namespace Doctrine\DBAL\Tests\Driver\PgSQL;

use Doctrine\DBAL\Driver as DriverInterface;
use Doctrine\DBAL\Driver\PgSQL\Driver;
use Doctrine\DBAL\Tests\Driver\AbstractPostgreSQLDriverTestCase;
use Doctrine\DBAL\Tests\TestUtil;

use function in_array;

class DriverTest extends AbstractPostgreSQLDriverTestCase
{
protected function setUp(): void
{
parent::setUp();

if (isset($GLOBALS['db_driver']) && $GLOBALS['db_driver'] === 'pgsql') {
return;
}

self::markTestSkipped('Test enabled only when using pgsql specific phpunit.xml');
}

/**
* Ensure we can handle URI notation for IPv6 addresses
*/
public function testConnectionIPv6(): void
{
if (! in_array($GLOBALS['db_host'], ['localhost', '127.0.0.1', '[::1]'], true)) {
// We cannot assume that every contributor runs the same setup as our CI
self::markTestSkipped('This test only works if there is a Postgres server listening on localhost.');
}

self::expectNotToPerformAssertions();

$params = TestUtil::getConnectionParams();
$params['host'] = '[::1]';

$this->driver->connect($params);
}

protected function createDriver(): DriverInterface
{
return new Driver();
}
}
Loading