fix(settings): add one-click internal state reset tool#1021
Open
faisalahammad wants to merge 1 commit intowp-media:developfrom
Open
fix(settings): add one-click internal state reset tool#1021faisalahammad wants to merge 1 commit intowp-media:developfrom
faisalahammad wants to merge 1 commit intowp-media:developfrom
Conversation
Add a settings-page troubleshooting action that clears stale Imagify transient and queue state without deleting user settings. Expose a dedicated admin-post endpoint with nonce and capability checks, add a troubleshooting section in settings, and clear stuck background batches plus related Action Scheduler jobs. Fixes wp-media#1012
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.
Summary
Add a one-click troubleshooting action in Imagify settings to reset stale internal optimization state without deleting user settings. This addresses recurring stuck optimization states caused by leftover transients, queue locks, and pending async jobs.
Fixes #1012
Problem
Users can hit persistent stuck optimization states (endless loading, stalled percentages, false quota-like state) even when server conditions are healthy. Current recovery is often plugin deactivate/reactivate or reinstall, which is disruptive.
Solution
Introduce a dedicated admin-post reset action and settings UI entry point that clears runtime state only: Imagify transients, stale background-process batches/locks, and pending Imagify Action Scheduler jobs. The reset is capability- and nonce-protected and keeps plugin settings intact.
Changes
inc/classes/class-imagify-admin-ajax-post.phpBefore:
After:
Why this works:
It provides a secure, explicit endpoint for the reset flow in wp-admin. Capability and nonce checks prevent unauthorized state resets, and existing redirect/notice plumbing provides immediate operator feedback.
inc/functions/admin.phpBefore:
After:
Why this works:
It centralizes runtime-state cleanup into one deterministic routine while preserving user configuration. It also targets both transient APIs and DB-level leftovers (batch/status keys), covering the failure modes seen in stuck-state support cases.
Settings UI
Before:
// no explicit troubleshooting reset entry point on settings pageAfter:
views/part-settings-troubleshooting.phpadds a nonce-protected button:Why this works:
It makes recovery available in a predictable place for admins without requiring reinstall/deactivation workflows.
Testing
Manual Testing
Test Case 1: UI visibility and action trigger
Test Case 2: Settings preservation
Test Case 3: Post-reset behavior
Automated Tests
$ vendor/bin/phpcs inc/classes/class-imagify-admin-ajax-post.php inc/functions/admin.php views/page-settings.php views/part-settings-troubleshooting.php .... 4 / 4 (100%) $ composer test-unit OK, but incomplete, skipped, or risky tests! Tests: 24, Assertions: 59, Risky: 5.Build Artifact
For manual verification, I built an installable package:
imagify-fix-issue-1012-reset-internal-state.zip
Installation:
WordPress Admin > Plugins > Add New > Upload PluginScreenshot