Skip to content

bug: Guard intropage height/shared column upgrades against duplicates - #475

Merged
TheWitness merged 1 commit into
developfrom
fix/intropage-height-dup-column
Nov 11, 2026
Merged

TheWitness merged 1 commit into
developfrom
fix/intropage-height-dup-column

Conversation

@TheWitness

@TheWitness TheWitness commented Nov 11, 2026 •

Copy link
Copy Markdown
Member

Problem

Applying the latest intropage logs repeated DB errors on console pages:

CMDPHP ERROR: A DB Exec Failed!, Error: Duplicate column name 'height'

The backtrace points at intropage_upgrade_database() in includes/database.php.

Root cause

The height (4.0.5 block) and shared (4.0.2 block) columns are each created in two places that both run during an upgrade:

  1. intropage_initialize_database() declares them in the schema passed to api_plugin_db_table_create(), which auto-adds any missing column to existing tables.
  2. intropage_upgrade_database() then runs a bare, unguarded ALTER TABLE ... ADD COLUMN.

Once the schema path has added the column, the ALTER fails with Duplicate column name. Unlike the neighboring upgrade steps, these two were missing a db_column_exists() guard.

Fix

Wrap both ALTERs in db_column_exists() checks so the upgrade steps are idempotent, matching the pattern already used by the surrounding blocks. No schema or behavior change on clean installs.

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>
Copilot AI balanced review requested due to automatic review settings November 11, 2026 19:53
@sonarqubecloud

Copy link
Copy Markdown

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

There are no active review issues for the column-existence guards added to the database upgrade steps.

No open issues 🎉

What changed in this PR

This PR prevents duplicate-column errors during Intropage database upgrades by checking whether columns already exist before adding them. Clean-install schemas remain unchanged.

Changes:

  • Guard the dashboard shared column addition with db_column_exists().
  • Guard both panel height column additions, matching neighboring upgrade steps.
File Description
includes/​database.php Adds existence checks to make the shared and height upgrade steps safe to repeat.

Review effort: Balanced

@somethingwithproof somethingwithproof left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No blockers found. Both guards match the db_column_exists() pattern of the neighboring upgrade steps, and the remaining ADD COLUMN statements in intropage_upgrade_database() are already guarded.

@TheWitness
TheWitness merged commit 9e50a7b into develop Nov 11, 2026
11 checks passed
@TheWitness
TheWitness deleted the fix/intropage-height-dup-column branch November 11, 2026 21:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants