Skip to content

v1.6.2 - Self-heal missing tables

Choose a tag to compare

@TaherSayed TaherSayed released this 24 May 14:55
· 15 commits to main since this release

Fixes a silent token-creation failure on installs upgraded via "Replace current with uploaded".

The bug

WordPress fires register_activation_hook on initial activation only, NOT on the in-place upgrade flow. If the cmcp_tokens table was missing for any reason (e.g. the previous version had been Deleted via admin, triggering uninstall.php, then the new version installed via Replace), wpdb->insert failed silently and the token never appeared in the Existing tokens list.

Fix

Plugin::maybe_upgrade() now runs on every load (hooked from Plugin::init). It compares the stored cmcp_version option against CMCP_VERSION. If they differ OR the primary wp_cmcp_tokens table is missing, it re-runs Plugin::activate() (which calls dbDelta). dbDelta is idempotent — existing tables with matching schema are untouched.

Upgrade

Install over the existing 1.6.1. On the next admin pageload, missing tables get created. Try creating a token — it should appear in the list immediately.