Skip to content

Commit 0dd4797

Browse files
committed
Merge branch '4.4.x' into 5.0.x
2 parents 5f56dfa + 742df57 commit 0dd4797

File tree

6 files changed

+102
-12
lines changed

6 files changed

+102
-12
lines changed

.github/workflows/continuous-integration.yml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ jobs:
131131
- "10.11" # LTS (Feb 2028) We have code specific to ^10.10
132132
- "11.4" # LTS (May 2029)
133133
- "11.8" # LTS (Jun 2028)
134+
- "12.0" # Rolling Release (Q4 2025)
134135
extension:
135136
- "mysqli"
136137
- "pdo_mysql"
@@ -191,18 +192,17 @@ jobs:
191192
- "Latin1_General_100_CI_AS_SC_UTF8"
192193
- "Latin1_General_100_CS_AS_SC_UTF8"
193194

194-
# The DB2 workflow currently segfaults with PHP 8.4
195-
# phpunit-ibm-db2:
196-
# name: "PHPUnit with IBM DB2"
197-
# needs: "phpunit-smoke-check"
198-
# uses: ./.github/workflows/phpunit-db2.yml
199-
# with:
200-
# php-version: ${{ matrix.php-version }}
201-
#
202-
# strategy:
203-
# matrix:
204-
# php-version:
205-
# - "8.4"
195+
phpunit-ibm-db2:
196+
name: "PHPUnit with IBM DB2"
197+
needs: "phpunit-smoke-check"
198+
uses: ./.github/workflows/phpunit-db2.yml
199+
with:
200+
php-version: ${{ matrix.php-version }}
201+
202+
strategy:
203+
matrix:
204+
php-version:
205+
- "8.4"
206206

207207
development-deps:
208208
name: "PHPUnit with PDO_SQLite and development dependencies"

UPGRADE.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,17 @@ all drivers and middleware.
381381

382382
# Upgrade to 4.4
383383

384+
## Deprecated dropping unnamed constraints in SQLite
385+
386+
Passing unnamed foreign key constraints as part of the `$droppedForeignKeys` argument of the `TableDiff` constructor
387+
has been deprecated.
388+
389+
## Deprecated overwriting foreign key constraints
390+
391+
Adding a foreign key constraint with a name that matches an existing one, whether explicitly specified or
392+
auto-generated, has been deprecated. In order to replace an existing constraint, drop it first
393+
via `dropForeignKey()`.
394+
384395
## Deprecated `View` features
385396

386397
The `View` constructor has been marked as internal. Use `View::editor()` to instantiate an editor and

src/Schema/Table.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -838,6 +838,15 @@ private function _addForeignKeyConstraint(ForeignKeyConstraint $constraint): sel
838838
$key = strtolower($this->generateNameFromObjectColumnNames('fk', $columnNames));
839839
}
840840

841+
if (isset($this->foreignKeyConstraints[$key])) {
842+
Deprecation::trigger(
843+
'doctrine/dbal',
844+
'https://github.com/doctrine/dbal/pull/7125',
845+
'Overwriting an existing foreign key constraint ("%s") is deprecated.',
846+
$key,
847+
);
848+
}
849+
841850
$this->foreignKeyConstraints[$key] = $constraint;
842851

843852
// add an explicit index on the foreign key columns.

src/Schema/TableDiff.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,16 @@ public function __construct(
4242
private readonly ?PrimaryKeyConstraint $addedPrimaryKeyConstraint = null,
4343
private readonly ?PrimaryKeyConstraint $droppedPrimaryKeyConstraint = null,
4444
) {
45+
foreach ($droppedForeignKeys as $droppedForeignKey) {
46+
if ($droppedForeignKey->getObjectName() === null) {
47+
Deprecation::trigger(
48+
'doctrine/dbal',
49+
'https://github.com/doctrine/dbal/pull/7143',
50+
'Dropping a foreign key constraints without specifying its name is deprecated.',
51+
);
52+
break;
53+
}
54+
}
4555
}
4656

4757
public function getOldTable(): Table

tests/Schema/TableDiffTest.php

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Doctrine\DBAL\Tests\Schema;
6+
7+
use Doctrine\DBAL\Schema\Column;
8+
use Doctrine\DBAL\Schema\ForeignKeyConstraint;
9+
use Doctrine\DBAL\Schema\Table;
10+
use Doctrine\DBAL\Schema\TableDiff;
11+
use Doctrine\DBAL\Types\Types;
12+
use Doctrine\Deprecations\PHPUnit\VerifyDeprecations;
13+
use PHPUnit\Framework\TestCase;
14+
15+
class TableDiffTest extends TestCase
16+
{
17+
use VerifyDeprecations;
18+
19+
public function testCreateWithInvalidDroppedForeignKeyName(): void
20+
{
21+
$table = Table::editor()
22+
->setUnquotedName('t1')
23+
->setColumns(
24+
Column::editor()
25+
->setUnquotedName('c1')
26+
->setTypeName(Types::INTEGER)
27+
->create(),
28+
)
29+
->create();
30+
31+
$droppedForeignKeys = ForeignKeyConstraint::editor()
32+
->setUnquotedReferencingColumnNames('c1')
33+
->setUnquotedReferencedTableName('t2')
34+
->setUnquotedReferencedColumnNames('c1')
35+
->create();
36+
37+
$this->expectDeprecationWithIdentifier('https://github.com/doctrine/dbal/pull/7143');
38+
39+
// @phpstan-ignore new.resultUnused
40+
new TableDiff($table, droppedForeignKeys: [$droppedForeignKeys]);
41+
}
42+
}

tests/Schema/TableTest.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1782,4 +1782,22 @@ public function testAddIndexWithConflictingFlags(array $flags): void
17821782
$this->expectException(InvalidIndexDefinition::class);
17831783
$table->addIndex(['user_id'], null, $flags);
17841784
}
1785+
1786+
public function testOverwritingForeignKeyConstraint(): void
1787+
{
1788+
$table = Table::editor()
1789+
->setUnquotedName('foo')
1790+
->setColumns(
1791+
Column::editor()
1792+
->setUnquotedName('id')
1793+
->setTypeName(Types::INTEGER)
1794+
->create(),
1795+
)
1796+
->create();
1797+
1798+
$table->addForeignKeyConstraint('bar', ['id'], ['id']);
1799+
1800+
$this->expectDeprecationWithIdentifier('https://github.com/doctrine/dbal/pull/7125');
1801+
$table->addForeignKeyConstraint('baz', ['id'], ['id']);
1802+
}
17851803
}

0 commit comments

Comments
 (0)