Skip to content

Commit 8b88e6d

Browse files
committed
Merge branch 'QA_5_2'
2 parents 0555e21 + d6ca244 commit 8b88e6d

1 file changed

Lines changed: 20 additions & 17 deletions

File tree

src/Tracking/Tracking.php

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -542,24 +542,27 @@ public function getHtmlForSchemaSnapshot(string $db, string $table, string $vers
542542
. '</a>]</h3>';
543543
$trackedData = $this->getTrackedData($db, $table, $version);
544544

545-
// Get first DROP TABLE/VIEW and CREATE TABLE/VIEW statements
546-
$dropCreateStatements = $trackedData->ddlog[0]['statement'];
547-
548-
if (
549-
str_contains($trackedData->ddlog[0]['statement'], 'DROP TABLE')
550-
|| str_contains($trackedData->ddlog[0]['statement'], 'DROP VIEW')
551-
) {
552-
$dropCreateStatements .= $trackedData->ddlog[1]['statement'];
553-
}
545+
// ddlog can be empty if all statements are deleted
546+
if ($trackedData->ddlog !== []) {
547+
// Get first DROP TABLE/VIEW and CREATE TABLE/VIEW statements
548+
$dropCreateStatements = $trackedData->ddlog[0]['statement'];
554549

555-
// Print SQL code
556-
$html .= Generator::getMessage(
557-
sprintf(
558-
__('Version %s snapshot (SQL code)'),
559-
htmlspecialchars($version),
560-
),
561-
$dropCreateStatements,
562-
);
550+
if (
551+
str_contains($trackedData->ddlog[0]['statement'], 'DROP TABLE')
552+
|| str_contains($trackedData->ddlog[0]['statement'], 'DROP VIEW')
553+
) {
554+
$dropCreateStatements .= $trackedData->ddlog[1]['statement'];
555+
}
556+
557+
// Print SQL code
558+
$html .= Generator::getMessage(
559+
sprintf(
560+
__('Version %s snapshot (SQL code)'),
561+
htmlspecialchars($version),
562+
),
563+
$dropCreateStatements,
564+
);
565+
}
563566

564567
// Unserialize snapshot
565568
$temp = Core::safeUnserialize($trackedData->schemaSnapshot);

0 commit comments

Comments
 (0)