Check if ddlog is not empty

Signed-off-by: Liviu-Mihail Concioiu <liviu.concioiu@gmail.com>
This commit is contained in:
Liviu-Mihail Concioiu 2026-03-05 00:01:32 +01:00
parent e70f9835d8
commit 2cf8bd02c3
3 changed files with 22 additions and 18 deletions

View File

@ -642,25 +642,28 @@ class Tracking
. '</a>]</h3>';
$data = Tracker::getTrackedData($_POST['db'], $_POST['table'], $_POST['version']);
// Get first DROP TABLE/VIEW and CREATE TABLE/VIEW statements
$drop_create_statements = $data['ddlog'][0]['statement'];
// ddlog can be empty if all statements are deleted
if ($data['ddlog'] !== []) {
// Get first DROP TABLE/VIEW and CREATE TABLE/VIEW statements
$drop_create_statements = $data['ddlog'][0]['statement'];
if (
mb_strstr($data['ddlog'][0]['statement'], 'DROP TABLE')
|| mb_strstr($data['ddlog'][0]['statement'], 'DROP VIEW')
) {
$drop_create_statements .= $data['ddlog'][1]['statement'];
if (
mb_strstr($data['ddlog'][0]['statement'], 'DROP TABLE')
|| mb_strstr($data['ddlog'][0]['statement'], 'DROP VIEW')
) {
$drop_create_statements .= $data['ddlog'][1]['statement'];
}
// Print SQL code
$html .= Generator::getMessage(
sprintf(
__('Version %s snapshot (SQL code)'),
htmlspecialchars($_POST['version'])
),
$drop_create_statements
);
}
// Print SQL code
$html .= Generator::getMessage(
sprintf(
__('Version %s snapshot (SQL code)'),
htmlspecialchars($_POST['version'])
),
$drop_create_statements
);
// Unserialize snapshot
$temp = Core::safeUnserialize($data['schema_snapshot']);
if ($temp === null) {

View File

@ -36537,7 +36537,7 @@ parameters:
-
message: "#^Cannot access offset 'ddlog' on mixed\\.$#"
count: 4
count: 1
path: libraries/classes/Tracking.php
-

View File

@ -13846,12 +13846,13 @@
<code>$str5</code>
<code>$value['Name']</code>
</MixedArgument>
<MixedArrayAccess occurrences="22">
<MixedArrayAccess occurrences="23">
<code>$data[$which_log][$delete_id]</code>
<code>$data['ddlog']</code>
<code>$data['ddlog']</code>
<code>$data['ddlog']</code>
<code>$data['ddlog']</code>
<code>$data['ddlog']</code>
<code>$data['schema_snapshot']</code>
<code>$entry['date']</code>
<code>$entry['date']</code>