Add reason for skipping regeneration in wp media regenerate#248
Add reason for skipping regeneration in wp media regenerate#248dr5hn wants to merge 2 commits intowp-cli:mainfrom
Conversation
When `wp media regenerate` skips a thumbnail, it now includes the specific reason in the output message (e.g., "no editor available for image/svg+xml"). This helps users understand why regeneration was skipped without needing to investigate further. Also adds `WP_CLI::debug()` output throughout the regeneration decision logic, providing detailed diagnostics when `--debug` is used (e.g., size changes detected, missing thumbnail files, all thumbnails up to date). Fixes wp-cli#95
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds clearer diagnostics for wp media regenerate by including a specific skip reason in user-facing output and by emitting detailed debug logs for regeneration decisions.
Changes:
- Include
needs_regeneration()skip reason in the “Skipped … regeneration” log line. - Add
WP_CLI::debug()messages covering key regeneration/skip decision paths. - Update Behat expectations to match the new skip message format.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/Media_Command.php | Adds skip-reason string plumbing and debug messages for regeneration decision logic. |
| features/media-regenerate.feature | Updates Behat assertions to expect the new “Skipped …: .” output. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Code Review
This pull request refactors the media regeneration logic to provide more detailed reasons when an attachment's thumbnail regeneration is skipped. The $skip_it variable, previously a boolean, now contains a descriptive string (e.g., "no editor available for image/svg+xml"), which is incorporated into WP_CLI::log output and various WP_CLI::debug messages. The feature tests have been updated to reflect these new, more descriptive output messages. The feedback suggests improving the clarity of a debug message by rephrasing "Skipping attachment" to "Skipping regeneration for attachment" to better distinguish between a full attachment skip and skipping regeneration for specific sizes.
- Remove trailing period from log format string; let the reason string itself carry punctuation to avoid doubled periods - Change debug message from "Skipping" to "Not regenerating" for the no-applicable-sizes path, since it is not counted as a skip
|
Hello! 👋 Thanks for opening this pull request! Please check out our contributing guidelines. We appreciate you taking the initiative to contribute to this project. Contributing isn't limited to just code. We encourage you to contribute in the way that best fits your abilities, by writing tutorials, giving a demo at your local meetup, helping other users with their support questions, or revising our documentation. Here are some useful Composer commands to get you started:
To run a single Behat test, you can use the following command: # Run all tests in a single file
composer behat features/some-feature.feature
# Run only a specific scenario (where 123 is the line number of the "Scenario:" title)
composer behat features/some-feature.feature:123You can find a list of all available Behat steps in our handbook. |
|
@swissspidy Thanks for flagging #201. Looked at that PR, it added separate log messages for PDF and empty metadata cases but was closed without merge. This PR takes a different approach: the skip reason is included directly in the existing skip message (e.g., Happy to adjust the approach if you'd prefer something closer to what #201 was doing. |
Summary
Fixes #95
When
wp media regenerateskips a thumbnail, the output message now includes the specific reason for the skip. This helps users understand immediately why regeneration was skipped without needing to investigate further.Additionally,
WP_CLI::debug()output has been added throughout the regeneration decision logic, providing detailed diagnostics when--debugis used.Changes
no editor available for image/svg+xml)WP_CLI::debug()calls for all decision paths inneeds_regeneration():Before
After
With
--debug:Test plan
wp media regenerate --yeson a site with SVG/PDF/BMP attachments and verify skip messages include the reasonwp media regenerate --yes --debugand verify debug output shows decision details for each attachmentvendor/bin/behat features/media-regenerate.featureSubmitted during WCAsia 2026 Contributor Day — tracked in wp-cli/wp-cli#6295