Skip to content

fix(settings): prevent settings from resetting on plugin update (#392) - #399

Merged
bmarshall511 merged 1 commit into
mainfrom
fix/392-settings-reset-on-update
Mar 16, 2026
Merged

bmarshall511 merged 1 commit into
mainfrom
fix/392-settings-reset-on-update

Conversation

@bmarshall511

Copy link
Copy Markdown
Collaborator

The legacy Updates class ran a migration from the old wpzerospam option to per-module zero-spam-{module} options on every plugin version bump, overwriting current user settings with stale values. This caused settings like "Log Blocked IPs" to re-enable themselves after each update. The issue was more consistent on Redis-based sites where the old option persisted reliably in the object cache.

Root causes:

  • Legacy migration ran on every update instead of once
  • Version tracking was gated inside the migration conditional
  • Old option values blindly overwrote current user preferences

Changes:

  • Replace Updates class with a proper Migrations runner that tracks completed migrations by unique key (each runs exactly once)
  • Legacy migration now only fills in MISSING keys — never overwrites existing user settings
  • Delete the stale wpzerospam option after migration with explicit cache flushing for Redis/Memcached environments
  • Add one-time dismissible admin notice prompting users to verify their settings after the fix
  • Clean up new options in uninstall.php

Closes #392

Description of the Change

Closes #

How to test the Change

Changelog Entry

Added - New feature
Changed - Existing functionality
Deprecated - Soon-to-be removed feature
Removed - Feature
Fixed - Bug fix
Security - Vulnerability

Credits

Props @username, @username2, ...

Checklist:

  • I agree to follow this project's Code of Conduct.
  • I have updated the documentation accordingly.
  • I have added tests to cover my change.
  • All new and existing tests pass.

The legacy Updates class ran a migration from the old `wpzerospam` option
to per-module `zero-spam-{module}` options on every plugin version bump,
overwriting current user settings with stale values. This caused settings
like "Log Blocked IPs" to re-enable themselves after each update. The
issue was more consistent on Redis-based sites where the old option
persisted reliably in the object cache.

Root causes:
- Legacy migration ran on every update instead of once
- Version tracking was gated inside the migration conditional
- Old option values blindly overwrote current user preferences

Changes:
- Replace Updates class with a proper Migrations runner that tracks
  completed migrations by unique key (each runs exactly once)
- Legacy migration now only fills in MISSING keys — never overwrites
  existing user settings
- Delete the stale `wpzerospam` option after migration with explicit
  cache flushing for Redis/Memcached environments
- Add one-time dismissible admin notice prompting users to verify
  their settings after the fix
- Clean up new options in uninstall.php

Closes #392

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@bmarshall511 bmarshall511 added this to the v5.7.8 milestone Mar 16, 2026
@bmarshall511
bmarshall511 requested a review from Copilot March 16, 2026 17:12
@bmarshall511 bmarshall511 self-assigned this Mar 16, 2026
@bmarshall511
bmarshall511 merged commit 91f7259 into main Mar 16, 2026
3 checks passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR replaces the legacy update mechanism with a one-time migration runner, fixes version tracking behavior, and adds an admin prompt for users to review settings after the migration fix.

Changes:

  • Replace Includes\Updates with a new Includes\Migrations runner that tracks completed migrations.
  • Add a one-time admin notice prompting settings review after migration and a nonce-protected dismissal action.
  • Extend uninstall cleanup to remove new migration/notice options.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
uninstall.php Deletes the new migration/notice options on uninstall (but single-site module option cleanup loop needs correction).
includes/class-updates.php Removes the legacy update/migration implementation.
includes/class-plugin.php Switches initialization from Updates to the new Migrations class.
includes/class-migrations.php Adds a migration runner and a legacy options migration, tracked via a completed-migrations option.
core/admin/class-settings.php Adds a nonce action to dismiss the settings review notice by deleting its option flag.
core/admin/class-admin.php Displays a one-time settings review notice in the admin UI.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread uninstall.php
delete_option( 'zerospam_completed_migrations' );
delete_option( 'zerospam_show_settings_review_notice' );

foreach ( $modules as $module => $settings ) {
'zero-spam'
);
?>
<div class="notice notice-warning is-dismissible" id="zerospam-settings-review-notice">
* other settings) to revert to defaults after plugin updates. This notice prompts
* administrators to verify their configuration after the fix has been applied.
*
* @since 5.7.9
@bmarshall511
bmarshall511 deleted the fix/392-settings-reset-on-update branch October 22, 2026 17:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

IP logging keeps getting re-enabled after updates

2 participants