Skip to content

Commit efe2095

Browse files
committed
Merge branch '4.3.x' into 5.0.x
2 parents b08207e + b299d3b commit efe2095

13 files changed

+158
-26
lines changed

.github/workflows/coding-standards.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ on:
2525
jobs:
2626
coding-standards:
2727
name: "Coding Standards"
28-
uses: "doctrine/.github/.github/workflows/coding-standards.yml@5.2.0"
28+
uses: "doctrine/.github/.github/workflows/coding-standards.yml@5.3.0"

.github/workflows/continuous-integration.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@ jobs:
541541
- name: "Install IBM DB2 CLI driver"
542542
working-directory: /tmp
543543
run: |
544-
wget https://public.dhe.ibm.com/ibmdl/export/pub/software/data/db2/drivers/odbc_cli/linuxx64_odbc_cli.tar.gz
544+
wget https://github.com/ibmdb/db2drivers/raw/refs/heads/main/clidriver/v11.5.9/linuxx64_odbc_cli.tar.gz
545545
tar xf linuxx64_odbc_cli.tar.gz
546546
rm linuxx64_odbc_cli.tar.gz
547547

.github/workflows/documentation.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ on:
1717
jobs:
1818
documentation:
1919
name: "Documentation"
20-
uses: "doctrine/.github/.github/workflows/documentation.yml@5.2.0"
20+
uses: "doctrine/.github/.github/workflows/documentation.yml@5.3.0"

UPGRADE.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,13 @@ all drivers and middleware.
5959

6060
# Upgrade to 4.3
6161

62+
## Deprecated configuration-related `Table` methods
63+
64+
The `Table::setSchemaConfig()` method and `$_schemaConfig` property have been deprecated. Pass a `TableConfiguration`
65+
instance to the constructor instead.
66+
67+
The `Table::_getMaxIdentifierLength()` method has been deprecated.
68+
6269
## Deprecated `AbstractAsset::_setName()`
6370

6471
Setting object name via `AbstractAsset::_setName()` has been deprecated. Pass the name to the `AbstractAsset`

psalm.xml.dist

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,24 @@
5555

5656
<!-- TODO for PHPUnit 11 -->
5757
<referencedMethod name="PHPUnit\Framework\TestCase::iniSet"/>
58+
59+
<!--
60+
https://github.com/doctrine/dbal/pull/6635
61+
TODO: remove in 5.0.0
62+
-->
63+
<referencedMethod name="Doctrine\DBAL\Schema\Table::_getMaxIdentifierLength" />
64+
<referencedMethod name="Doctrine\DBAL\Schema\Table::setSchemaConfig" />
5865
</errorLevel>
5966
</DeprecatedMethod>
67+
<DeprecatedProperty>
68+
<errorLevel type="suppress">
69+
<!--
70+
https://github.com/doctrine/dbal/pull/6635
71+
TODO: remove in 5.0.0
72+
-->
73+
<referencedProperty name="Doctrine\DBAL\Schema\Table::$_schemaConfig" />
74+
</errorLevel>
75+
</DeprecatedProperty>
6076
<DocblockTypeContradiction>
6177
<errorLevel type="suppress">
6278
<!--

src/Schema/AbstractSchemaManager.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,9 @@ public function listTables(): array
202202
$filter = $this->connection->getConfiguration()->getSchemaAssetsFilter();
203203
$tables = [];
204204

205+
$configuration = $this->createSchemaConfig()
206+
->toTableConfiguration();
207+
205208
foreach ($tableColumnsByTable as $tableName => $tableColumns) {
206209
if (! $filter($tableName)) {
207210
continue;
@@ -214,6 +217,7 @@ public function listTables(): array
214217
[],
215218
$this->_getPortableTableForeignKeysList($foreignKeyColumnsByTable[$tableName] ?? []),
216219
$tableOptionsByTable[$tableName] ?? [],
220+
$configuration,
217221
);
218222
}
219223

src/Schema/Schema.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ public function __construct(
8383
}
8484

8585
foreach ($tables as $table) {
86+
$table->setSchemaConfig($this->_schemaConfig);
8687
$this->_addTable($table);
8788
}
8889

@@ -109,7 +110,6 @@ protected function _addTable(Table $table): void
109110
}
110111

111112
$this->_tables[$tableName] = $table;
112-
$table->setSchemaConfig($this->_schemaConfig);
113113
}
114114

115115
protected function _addSequence(Sequence $sequence): void
@@ -270,7 +270,7 @@ public function createNamespace(string $name): self
270270
*/
271271
public function createTable(string $name): Table
272272
{
273-
$table = new Table($name);
273+
$table = new Table($name, [], [], [], [], [], $this->_schemaConfig->toTableConfiguration());
274274
$this->_addTable($table);
275275

276276
foreach ($this->_schemaConfig->getDefaultTableOptions() as $option => $value) {

src/Schema/SchemaConfig.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,9 @@ public function setDefaultTableOptions(array $defaultTableOptions): void
5858
{
5959
$this->defaultTableOptions = $defaultTableOptions;
6060
}
61+
62+
public function toTableConfiguration(): TableConfiguration
63+
{
64+
return new TableConfiguration($this->maxIdentifierLength);
65+
}
6166
}

src/Schema/Table.php

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,11 @@ class Table extends AbstractAsset
6161
'create_options' => [],
6262
];
6363

64+
/** @deprecated Pass a {@link TableConfiguration} instance to the constructor instead. */
6465
protected ?SchemaConfig $_schemaConfig = null;
6566

67+
private int $maxIdentifierLength;
68+
6669
/**
6770
* @param array<Column> $columns
6871
* @param array<Index> $indexes
@@ -77,13 +80,18 @@ public function __construct(
7780
array $uniqueConstraints = [],
7881
array $fkConstraints = [],
7982
array $options = [],
83+
?TableConfiguration $configuration = null,
8084
) {
8185
if ($name === '') {
8286
throw InvalidTableName::new($name);
8387
}
8488

8589
parent::__construct($name);
8690

91+
$configuration ??= (new SchemaConfig())->toTableConfiguration();
92+
93+
$this->maxIdentifierLength = $configuration->getMaxIdentifierLength();
94+
8795
foreach ($columns as $column) {
8896
$this->_addColumn($column);
8997
}
@@ -103,9 +111,19 @@ public function __construct(
103111
$this->_options = array_merge($this->_options, $options);
104112
}
105113

114+
/** @deprecated Pass a {@link TableConfiguration} instance to the constructor instead. */
106115
public function setSchemaConfig(SchemaConfig $schemaConfig): void
107116
{
117+
Deprecation::triggerIfCalledFromOutside(
118+
'doctrine/dbal',
119+
'https://github.com/doctrine/dbal/pull/6635',
120+
'%s is deprecated. Pass TableConfiguration to the constructor instead.',
121+
__METHOD__,
122+
);
123+
108124
$this->_schemaConfig = $schemaConfig;
125+
126+
$this->maxIdentifierLength = $schemaConfig->getMaxIdentifierLength();
109127
}
110128

111129
/**
@@ -623,11 +641,17 @@ public function __clone()
623641
}
624642
}
625643

644+
/** @deprecated */
626645
protected function _getMaxIdentifierLength(): int
627646
{
628-
return $this->_schemaConfig instanceof SchemaConfig
629-
? $this->_schemaConfig->getMaxIdentifierLength()
630-
: 63;
647+
Deprecation::triggerIfCalledFromOutside(
648+
'doctrine/dbal',
649+
'https://github.com/doctrine/dbal/pull/6635',
650+
'%s is deprecated.',
651+
__METHOD__,
652+
);
653+
654+
return $this->maxIdentifierLength;
631655
}
632656

633657
protected function _addColumn(Column $column): void

src/Schema/TableConfiguration.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Doctrine\DBAL\Schema;
6+
7+
/**
8+
* Contains platform-specific parameters used for creating and managing objects scoped to a {@see Table}.
9+
*/
10+
class TableConfiguration
11+
{
12+
/** @internal The configuration can be only instantiated by a {@see SchemaConfig}. */
13+
public function __construct(private readonly int $maxIdentifierLength)
14+
{
15+
}
16+
17+
/**
18+
* Returns the maximum length of identifiers to be generated for the objects scoped to the table.
19+
*/
20+
public function getMaxIdentifierLength(): int
21+
{
22+
return $this->maxIdentifierLength;
23+
}
24+
}

0 commit comments

Comments
 (0)