fix: prevent default fallback image from entering the import pipeline#1283
Open
Alexia-Soare wants to merge 2 commits into
Open
fix: prevent default fallback image from entering the import pipeline#1283Alexia-Soare wants to merge 2 commits into
Alexia-Soare wants to merge 2 commits into
Conversation
Import jobs identified by __jobID no longer receive the display fallback image (bundled SVG) from feedzy_retrieve_image(). This stops Media Library upload errors for feedzy.svg on WP-CLI-based cron runners and duplicate re-uploads of a configured fallback attachment. Imports rely on the default thumbnail setting via set_post_thumbnail() instead. Fixes #1277 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Contributor
|
Plugin build for 02f6299 is ready 🛎️!
Note You can preview the changes in the Playground |
CI environments make unrelated background HTTP requests during the test run; restrict the assertion to the traffic the bug produces (bundled feedzy.svg or the site's own fallback attachment). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
Imports triggered by WP-CLI-based cron runners (common on managed hosts) injected the bundled
img/feedzy.svgas the item image and tried to upload it to the Media Library, which WordPress rejects — filling customer logs withCannot upload the image to Media Libraryerrors (#1277). Imports now never use the display fallback image and rely on the default thumbnail setting instead.What changed
The old guard in
feedzy_define_default_image()detected imports by runtime context (wp_doing_cron()+ therun_nowAJAX check), which WP-CLI cron runners bypass. Every import run already carries$options['__jobID'], so the guard now keys off that.feedzy_retrieve_image()skips thefeedzy_default_imagefallback when$sc['__jobID']is set; all import entry points (Run Now, wp-cron, WP-CLI cron) now behave identically.set_post_thumbnail()with no HTTP request.featured_imagefilter conditions: used to match every item on the leaky path (the injected SVG counted as the item's image); now they evaluate the item's real image.__jobID, so the fallback image still renders.Saved featured image…debug line fired even when saving failed; it now reportsSuccess: yes/no.Import flow
flowchart TD A[Feed item has no image] --> B{__jobID in options?} B -- "no (display: shortcode/block)" --> C[feedzy_default_image filter renders fallback in img tag] B -- "yes (import)" --> D[Skip display fallback]:::changed D --> E{Default thumbnail configured?} E -- yes --> F[set_post_thumbnail with attachment ID] E -- no --> G[Post imported without featured image, accurate log]:::changed classDef changed fill:#9a6700,color:#fff,stroke:#9a6700🟨 changed by this PR, gray/default unchanged.
Verification
feedzy_retrieve_image()(import suppresses the fallback, display keeps it, real item images unaffected) and one end-to-endrun_cron()test asserting the fallback thumbnail is applied with no Media Library upload and no fallback-image HTTP fetch.feedzy_retrieve_image()fromdevelopment): it records two HTTP fetches of the fallback attachment.wp eval 'do_action("feedzy_cron", 100, <job_id>);'with Logging Level set to Debug. Expected: posts import; logs contain nofeedzy.svgand noCannot upload the image to Media Library.[feedzy-rss]shortcode or Feedzy block for the same feed in a browser. Expected: the default image still appears for imageless items.Risk: Feedzy PRO already passes
__jobIDaround (see the_dry_run_tags_handling in the abstract class); if PRO builds import options anywhere without routing throughrun_job(), that path would miss the guard — worth a quick check on the PRO side.🤖 Generated with Claude Code