Skip to content

Commit 4420bfe

Browse files
committed
ACP2E-1709: error during declarative schema whitelsit generation
1 parent 4a41ec4 commit 4420bfe

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

app/code/Magento/Developer/Model/Setup/Declaration/Schema/WhitelistGenerator.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use Magento\Framework\Setup\Declaration\Schema\Declaration\TableElement\ElementNameResolver;
1818
use Magento\Framework\Setup\Declaration\Schema\Diff\Diff;
1919
use Magento\Framework\Setup\Declaration\Schema\Dto\Schema;
20+
use Magento\Framework\Setup\Declaration\Schema\Dto\Table;
2021
use Magento\Framework\Setup\Declaration\Schema\SchemaConfig;
2122
use Magento\Framework\Setup\JsonPersistor;
2223

@@ -192,6 +193,9 @@ private function getElementsWithAutogeneratedName(Schema $schema, string $tableN
192193
$elementType = 'index';
193194
if (!empty($tableData[$elementType])) {
194195
foreach ($tableData[$elementType] as $tableElementData) {
196+
if (!isset($tableElementData['column'])) {
197+
continue;
198+
}
195199
$indexName = $this->elementNameResolver->getFullIndexName(
196200
$table,
197201
$tableElementData['column'],
@@ -201,9 +205,30 @@ private function getElementsWithAutogeneratedName(Schema $schema, string $tableN
201205
}
202206
}
203207

208+
$constraintName = $this->getConstraintName($schema, $table, $tableData);
209+
if ($constraintName) {
210+
$declaredStructure += $constraintName;
211+
}
212+
213+
return $declaredStructure;
214+
}
215+
216+
/**
217+
* @param Schema $schema
218+
* @param Table $table
219+
* @param array $tableData
220+
* @return array
221+
*/
222+
private function getConstraintName(Schema $schema, Table $table, array $tableData): array
223+
{
224+
$declaredStructure = [];
225+
204226
$elementType = 'constraint';
205227
if (!empty($tableData[$elementType])) {
206228
foreach ($tableData[$elementType] as $tableElementData) {
229+
if (!isset($tableElementData['referenceTable'])) {
230+
continue;
231+
}
207232
if ($tableElementData['type'] === 'foreign') {
208233
$referenceTable = $schema->getTableByName($tableElementData['referenceTable']);
209234
$column = $table->getColumnByName($tableElementData['column']);
@@ -216,6 +241,9 @@ private function getElementsWithAutogeneratedName(Schema $schema, string $tableN
216241
$referenceColumn
217242
) : null;
218243
} else {
244+
if (!isset($tableElementData['column'])) {
245+
continue;
246+
}
219247
$constraintName = $this->elementNameResolver->getFullIndexName(
220248
$table,
221249
$tableElementData['column'],

0 commit comments

Comments
 (0)