Repository navigation
fix(settings): prevent settings from resetting on plugin update (#392) - #399
Merged
Merged
Conversation
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>
There was a problem hiding this comment.
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\Updateswith a newIncludes\Migrationsrunner 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.
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The legacy Updates class ran a migration from the old
wpzerospamoption to per-modulezero-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:
Changes:
wpzerospamoption after migration with explicit cache flushing for Redis/Memcached environmentsCloses #392
Description of the Change
Closes #
How to test the Change
Changelog Entry
Credits
Props @username, @username2, ...
Checklist: