From 36e369566b5ac27436f92b377448fceccb9a3802 Mon Sep 17 00:00:00 2001 From: TheWitness Date: Wed, 11 Nov 2026 14:53:38 -0500 Subject: [PATCH] bug: Guard intropage height/shared column upgrades against duplicates The 4.0.2 'shared' and 4.0.5 'height' upgrade steps ran unguarded ALTER TABLE ... ADD COLUMN statements. Because those same columns are also declared in intropage_initialize_database()'s schema, which api_plugin_db_table_create() auto-adds to existing tables, the column can already exist when the upgrade step runs, producing repeated 'Duplicate column name' DB errors on console pages. Wrap both ALTERs in db_column_exists() checks so the steps are idempotent, matching the pattern already used by the surrounding upgrade blocks. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- includes/database.php | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/includes/database.php b/includes/database.php index b16c226..6ccfc50 100644 --- a/includes/database.php +++ b/includes/database.php @@ -392,7 +392,9 @@ function intropage_upgrade_database(): void { db_execute("UPDATE plugin_intropage_panel_definition SET panel_id='ntp_dns', name='NTP/DNS check' WHERE panel_id='ntp'"); db_execute("UPDATE plugin_intropage_panel_data SET panel_id='ntp_dns' WHERE panel_id='ntp'"); db_execute("UPDATE plugin_intropage_user_auth set permissions=REPLACE(permissions,'ntp','ntp_dns')"); - db_execute('ALTER TABLE plugin_intropage_dashboard ADD COLUMN shared INT(1) NOT NULL default "0"'); + if (!db_column_exists('plugin_intropage_dashboard', 'shared')) { + db_execute('ALTER TABLE plugin_intropage_dashboard ADD COLUMN shared INT(1) NOT NULL default "0"'); + } db_execute('DELETE FROM plugin_hooks WHERE FUNCTION = "intropage_config_form" AND name="intropage"'); } @@ -420,10 +422,15 @@ function intropage_upgrade_database(): void { } if (cacti_version_compare($oldv, '4.0.5', '<=')) { - db_execute('ALTER TABLE plugin_intropage_panel_definition - ADD COLUMN `height` enum("normal","double","triple") NOT NULL DEFAULT "normal"'); - db_execute('ALTER TABLE plugin_intropage_panel_data - ADD COLUMN `height` enum("normal","double","triple") NOT NULL DEFAULT "normal"'); + if (!db_column_exists('plugin_intropage_panel_definition', 'height')) { + db_execute('ALTER TABLE plugin_intropage_panel_definition + ADD COLUMN `height` enum("normal","double","triple") NOT NULL DEFAULT "normal"'); + } + + if (!db_column_exists('plugin_intropage_panel_data', 'height')) { + db_execute('ALTER TABLE plugin_intropage_panel_data + ADD COLUMN `height` enum("normal","double","triple") NOT NULL DEFAULT "normal"'); + } } if (cacti_version_compare($oldv, '4.1.0', '<')) {