Skip to content

Commit

Permalink
Fix undefined variable when assert() is disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-grekas committed Oct 20, 2020
1 parent b85809c commit 3a05ae9
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions lib/Doctrine/DBAL/Schema/PostgreSqlSchemaManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,17 +154,21 @@ protected function _getPortableTableForeignKeyDefinition($tableForeignKey)
$onDelete = $match[1];
}

assert(preg_match(
$match = preg_match(
'/FOREIGN KEY \((.+)\) REFERENCES (.+)\((.+)\)/',
$tableForeignKey['condef'],
$values
) !== 0);
);

assert($match !== 0);

// PostgreSQL returns identifiers that are keywords with quotes, we need them later, don't get
// the idea to trim them here.
$localColumns = array_map('trim', explode(',', $values[1]));
$foreignColumns = array_map('trim', explode(',', $values[3]));
$foreignTable = $values[2];
if ($match) {
// PostgreSQL returns identifiers that are keywords with quotes, we need them later, don't get
// the idea to trim them here.
$localColumns = array_map('trim', explode(',', $values[1]));
$foreignColumns = array_map('trim', explode(',', $values[3]));
$foreignTable = $values[2];
}

return new ForeignKeyConstraint(
$localColumns,
Expand Down

0 comments on commit 3a05ae9

Please sign in to comment.