You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: Handle missing table in DB repair — use activate() with dbDelta
The repair notice was showing indefinitely because:
1. is_database_schema_valid() checked only for a missing column,
not a missing table — SHOW COLUMNS on a non-existent table
returns empty, causing false positives
2. The repair handler called maybe_upgrade() which runs ALTER TABLE,
which fails when the table itself doesn't exist
Changes:
- is_database_schema_valid() now checks SHOW TABLES first, then
checks for the opt_in_token column
- handle_database_upgrade() now calls MSKD_Activator::activate()
which uses dbDelta to create missing tables and all their columns
- Removed the direct ALTER TABLE fallback (wrong for missing tables)
- Error notice now shows DB error and suggests deactivate/reactivate
- Repair notice text updated to mention tables as well as columns
Copy file name to clipboardExpand all lines: CHANGELOG.md
+3Lines changed: 3 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
8
8
## [Unreleased]
9
9
10
+
### Fixed
11
+
-**Database repair notice persisting infinitely** — when clicking "Repair Database Now", if the required database table or column did not exist (or `ALTER TABLE` silently failed), the repair notice was shown on every page load indefinitely. The handler now calls `MSKD_Activator::activate()` (which uses `dbDelta` to create missing tables and columns), verifies the schema afterwards, and — if still failing — shows an actionable error notice with the database error message. The schema check also now correctly detects a missing table (not just a missing column).
12
+
10
13
### Changed
11
14
-**Delete Inactive Subscribers button** now also deletes subscribers with `unsubscribed` status, in addition to `inactive` (unconfirmed). Updated button description, confirmation dialog, and success messages accordingly. Translations updated for Bulgarian and German.
<?phpesc_html_e( 'Database repair failed. One or more required tables or columns could not be created. Please deactivate and reactivate the plugin, or contact your hosting provider if the issue persists.', 'mail-system-by-katsarov-design' ); ?>
@@ -253,7 +282,7 @@ private function render_database_repair_notice(): void {
253
282
<strong><?phpesc_html_e( 'Mail System Database Repair Required', 'mail-system-by-katsarov-design' ); ?></strong>
254
283
</p>
255
284
<p>
256
-
<?phpesc_html_e( 'Some required database columns are missing. This may cause subscription confirmation links to fail. Click the button below to repair the database.', 'mail-system-by-katsarov-design' ); ?>
285
+
<?phpesc_html_e( 'Some required database tables or columns are missing. This may cause subscription confirmation links to fail. Click the button below to repair the database.', 'mail-system-by-katsarov-design' ); ?>
0 commit comments