Retry restore of offloaded images that previously failed rollback#1091
Merged
Conversation
selul
requested changes
Jul 9, 2026
| count: 1 | ||
| path: inc/media_offload.php | ||
|
|
||
| - |
Contributor
Author
There was a problem hiding this comment.
Fixed in 6c9b1c5. The baseline entries were stale — both clear_offload_errors_meta() and clear_rollback_errors_meta() have @return int|bool PHPDoc, which satisfies PHPStan's missingType.return rule, so the ignore entries no longer matched. Removed both.
Contributor
Author
There was a problem hiding this comment.
Correction: the fix is in commit e837999.
Copilot
AI
changed the title
[WIP] Fix restore of offloaded images to consider previously failed rollbacks
Retry restore of offloaded images that previously failed rollback
Jul 9, 2026
Collaborator
selul
approved these changes
Jul 9, 2026
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.
Failed rollbacks tag attachments with
optimole_rollback_error, and the rollback selection query excludes tagged attachments. Because the clear-errors path only removedoptimole_offload_error, retrying a restore silently skipped the images that had failed — potentially leaving them permanently unavailable locally. The offload flow already clears its error flags before retrying; the rollback flow did not.Changes
inc/media_offload.php— Parametrizedclear_offload_errors_meta()with an optional meta key (defaults to the offload-error key) and addedclear_rollback_errors_meta()to deleteoptimole_rollback_error.inc/rest.php—clear_offload_errors()clears rollback errors when the requestactionisrollback_images, offload errors otherwise.assets/src/dashboard/utils/api.js—clearOffloadErrors()takes anaction(defaultoffload_images) forwarded as a query arg.assets/src/dashboard/parts/connected/settings/OffloadMedia.js—onRollbackdMedia()awaitsclearOffloadErrors('rollback_images')before syncing, mirroring the offload path.inc/cli/cli_media.php— WP-CLI rollback clears rollback errors too, since it shares the rollback query.tests/test-media.php— Added coverage: an offloaded attachment withoptimole_rollback_erroris excluded from rollback selection, then eligible again afterclear_rollback_errors_meta().Rollback flow, before → after
Note: the dashboard JS change requires rebuilding
assets/build/(npm run build:dashboard); build artifacts are intentionally excluded from this diff.