Repository navigation
fix: include feed source URL and import ID in log context for easier troubleshooting - #1284
Conversation
…troubleshooting Scope the logger context to each import run so every entry written while a job runs carries import_id, import_title and source; log single-feed parse failures that were previously swallowed; surface the import and feed URL as badges in the logs viewer with fallbacks for legacy job_id/source entries. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Plugin build for 9187d22 is ready 🛎️!
Note You can preview the changes in the Playground |
The Translations Diff CI job fails on any POT change; render the import ID as a plain (#ID) suffix and drop the badge tooltips so the badges add no new strings. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Add direct-access guards to 26 PHP files; replace unlink() with wp_delete_file(); annotate the deliberate direct-filesystem fast paths; rename chosen-sprite@2x.png (special character) and the SimplePie util file that false-matched the core-library check (class name unchanged, resolved via an autoloader class map). Also raise the run-now wait timeout in the e2e helper for slow import runs. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
| // Class files named differently from the autoloader convention | ||
| // (e.g. to avoid matching core-library filename patterns). | ||
| $class_map = array( | ||
| 'Feedzy_Rss_Feeds_Util_SimplePie' => 'includes/util/feedzy-rss-feeds-util-feed.php', | ||
| ); | ||
| if ( isset( $class_map[ $class_to_load ] ) ) { | ||
| require_once plugin_dir_path( __FILE__ ) . $class_map[ $class_to_load ]; | ||
|
|
||
| return true; | ||
| } |
There was a problem hiding this comment.
I think we can remove this.
…Util_Feed Match the class name to its file (feedzy-rss-feeds-util-feed.php) so the autoloader's naming convention resolves it, and drop the special-case class map from feedzy_rss_feeds_autoload(). Addresses review feedback: #1284 (review) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Adds import/feed attribution to logs and improves troubleshooting, alongside Plugin Check cleanup.
Changes:
- Adds scoped import context and feed parsing error attribution.
- Displays import/source badges with legacy fallbacks and E2E coverage.
- Adds access guards, safer file deletion, and asset/class renames.
Reviewed changes
Copilot reviewed 35 out of 36 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
tests/e2e/utils.js |
Adds log-test helpers and import utilities. |
tests/e2e/specs/log-attribution.spec.js |
Tests log attribution flows. |
phpstan-baseline.neon |
Updates renamed utility references. |
includes/views/wordai-view.php |
Adds direct-access guard. |
includes/views/spinnerchief-view.php |
Adds direct-access guard. |
includes/views/openrouter-view.php |
Adds direct-access guard. |
includes/views/openai-view.php |
Adds direct-access guard. |
includes/views/misc-view.php |
Adds direct-access guard. |
includes/views/import-metabox-edit.php |
Adds direct-access guard. |
includes/views/css/chosen.css |
References renamed sprite. |
includes/views/css/chosen-sprite-2x.png |
Renames high-resolution sprite. |
includes/views/amazon-product-advertising-view.php |
Adds direct-access guard. |
includes/views/ai-quota-view.php |
Adds direct-access guard. |
includes/util/feedzy-rss-feeds-util-feed.php |
Renames the SimplePie utility class/file. |
includes/layouts/setup-wizard.php |
Adds direct-access guard. |
includes/layouts/settings.php |
Adds direct-access guard. |
includes/layouts/integration.php |
Adds direct-access guard. |
includes/layouts/header.php |
Adds direct-access guard. |
includes/layouts/feedzy-tutorial.php |
Adds direct-access guard. |
includes/layouts/feedzy-support.php |
Adds direct-access guard. |
includes/layouts/feedzy-subscribe-notice.php |
Adds direct-access guard. |
includes/layouts/feedzy-schedules.php |
Adds direct-access guard. |
includes/layouts/feedzy-pro.php |
Adds direct-access guard. |
includes/layouts/feedzy-logs-viewer.php |
Renders attribution badges and fallbacks. |
includes/layouts/feedzy-license.php |
Adds direct-access guard. |
includes/layouts/feedzy-improve.php |
Adds direct-access guard. |
includes/layouts/feedzy-documentation.php |
Adds direct-access guard. |
includes/feedzy-rss-feeds-feed-tweaks.php |
Adds direct-access guard. |
includes/admin/feedzy-rss-feeds-upgrader.php |
Adds direct-access guard. |
includes/admin/feedzy-rss-feeds-options.php |
Adds direct-access guard. |
includes/admin/feedzy-rss-feeds-log.php |
Documents direct filesystem operations. |
includes/admin/feedzy-rss-feeds-import.php |
Scopes log context and modernizes file deletion. |
includes/admin/feedzy-rss-feeds-actions.php |
Adds direct-access guard. |
includes/abstract/feedzy-rss-feeds-admin-abstract.php |
Logs single-feed failures with URLs. |
form/form.php |
Adds direct-access guard. |
css/settings.css |
Styles attribution badges. |
Comments suppressed due to low confidence (1)
includes/util/feedzy-rss-feeds-util-feed.php:31
- Renaming this public class removes the autoload target for
Feedzy_Rss_Feeds_Util_SimplePie. Any extension that still instantiates the old class will now fail before this new file is loaded, and there is no compatibility alias or autoloader mapping. Please keep the old class name resolvable while avoiding the flagged filename, for example via a bootstrap/autoloader alias to this class.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| await page | ||
| .locator('tr', { hasText: importName }) | ||
| .getByRole('button', { name: 'Run Now' }) | ||
| .click(); | ||
|
|
||
| const runNowResponse = await page.waitForResponse( | ||
| (response) => | ||
| response.url().includes('/wp-admin/admin-ajax.php') && | ||
| response.request().method() === 'POST' && | ||
| response | ||
| .request() | ||
| .postData() | ||
| .includes('action=feedzy&_action=run_now'), | ||
| // Importing a feed can take a while (remote fetch + image sideloads). | ||
| { timeout: 60000 } | ||
| ); |
| // Backward compatibility: entries whose context has no attribution keys | ||
| // (this one only has a `feed_urls` array) render fine, without a badge row. | ||
| const keylessEntry = page.locator('.fz-log-container', { |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 35 out of 36 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
tests/e2e/utils.js:297
- Register the response waiter before clicking. As written, the AJAX response can arrive after the click is dispatched but before
waitForResponse()starts listening, causing this helper to wait 60 seconds and time out even though the import completed. Start the click and waiter together withPromise.all, as is required for event-triggering Playwright actions.
| $logger->set_context( | ||
| array( | ||
| 'import_id' => $job->ID, | ||
| 'import_title' => $job->post_title, |
|
@lucadobrescu ask Fable to review the copilot comments |
- Use a distinct `import_post_title` context key for the post-title mapping template so it no longer clobbers the `import_title` job attribution set in run_job() - Register the run-now AJAX response listener before clicking in runImportByName and runFeedImport so fast responses are not missed - Cover the legacy log-context fallback: a test-only mu-plugin seeds an entry carrying only `job_id`/`source` and the spec asserts both badges render from those keys Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- @wordpress/env ^9.10.0 -> ^11.11.0 and @wordpress/e2e-test-utils-playwright ^0.26.0 -> ^1.51.0, matching the versions chosen in #1288 - pin adm-zip 0.5.18 in the lockfile: 0.5.12's broken extractAllToAsync makes wp-env 11 exit 0 without starting any container - raise Playwright actionTimeout to 30s; feedzy blocks fetch remote feeds during save/render and exceed the 10s default on CI Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
@lucadobrescu let's solve the merge conflict here |
…feed-context # Conflicts: # package-lock.json # tests/e2e/utils.js
…ed class The health test added on development still referenced the old Feedzy_Rss_Feeds_Util_SimplePie class name, which this branch renamed. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This reverts commit 46e3b5b.
YouTube intermittently throttles GitHub runner IPs, making the classic-block embed-youtube-video test fail on the feed fetch. Feedzy fetches feeds through WP_SimplePie_File (the WP HTTP API), so a pre_http_request filter in a test-only mu-plugin can serve a canned YouTube Atom feed deterministically. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 39 out of 41 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (1)
tests/e2e/utils.js:306
Request.postData()can returnnull. Since this predicate evaluates every POST response toadmin-ajax.php, an unrelated bodyless request can throw before the import response arrives and make the E2E test flaky. Guard it with optional chaining, asrunFeedImport()already does.
…cate Copilot review follow-up: an unrelated bodyless POST to admin-ajax.php could throw inside the waitForResponse predicate and flake the test. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Re: Copilot review — the suppressed low-confidence note on Fixed in fb7b4a0 by using the same |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 39 out of 41 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (4)
includes/admin/feedzy-rss-feeds-import.php:1633
- The second
run_job()call also clears the scoped context before this debug entry, so this message cannot render the promised feed-source badge. Includesourcein the explicit context as well.
'job_id' => $job->ID,
'import_id' => $job->ID,
'import_title' => $job->post_title,
'result' => $result,
includes/admin/feedzy-rss-feeds-import.php:1418
- This manual-run info entry is emitted before
run_job()installs the persistent context, so it gets the import badge but not the source badge. That contradicts the PR's QA expectation that info/debug entries from a run carry both badges. Include the job source explicitly here.
'job_id' => $job_id,
'import_id' => (int) $job_id,
'import_title' => isset( $job->post_title ) ? $job->post_title : '',
includes/admin/feedzy-rss-feeds-import.php:1620
run_job()clears its persistent context infinallybefore this completion entry is written, and this explicit context omitssource. The resulting cron debug entry has no feed-source badge despite the stated attribution behavior. Add the job source to this context.
This issue also appears on line 1630 of the same file.
'job_id' => $job->ID,
'import_id' => $job->ID,
'import_title' => $job->post_title,
'result' => $result,
includes/admin/feedzy-rss-feeds-import.php:1650
- When
run_job()throws, itsfinallyblock clears the scoped source before this error is logged. Because the replacement context adds only import fields, failures that escape the job logic lose the feed-source badge. Add the source explicitly.
'job_id' => $job->ID,
'import_id' => $job->ID,
'import_title' => $job->post_title,
'error' => $e->getMessage(),
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 39 out of 41 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (2)
includes/util/feedzy-rss-feeds-util-feed.php:31
- This rename removes the old autoloadable class entirely. Any extension that constructs or type-checks
Feedzy_Rss_Feeds_Util_SimplePiewill now fail with “class not found,” even though this is only a patch release. Please retain a compatibility alias and teach the autoloader to load this renamed file when the legacy class is requested; that preserves integrations without restoring the filename that Plugin Check rejects.
includes/admin/feedzy-rss-feeds-import.php:1685 - Clearing the singleton context here also discards any context that was already set before the import (for example, request or integration metadata set through the existing public
set_context()API). This scope should save the previous context and restore it infinally, rather than resetting all logger state after each job.
$logger->set_context( array() );
…learing it run_job() reset the logger context to an empty array in its finally block, discarding any context set through the public set_context() API before the import ran. Save the previous context and restore it instead, via a new get_context() accessor. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Re: the two low-confidence notes in Copilot's review:
|
PHPStan flagged includes/admin/feedzy-rss-feeds-import.php:1449 after #1284 merged into development. $job is already guarded by the ! $job bail above, and the other call sites in this file read $job->post_title directly.
|
🎉 This PR is included in version 5.2.7 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
Feedzy logs couldn't tell you which import produced an entry, so users with multiple feeds couldn't trace an error back to its source (#1278, from HelpScout conversation 3380282141). This PR tags every log entry written during an import run with the import's ID, title and source, and surfaces them as badges in the log viewer.
What changed
run_job()— now a thin wrapper that sets persistent logger context (import_id,import_title,source) through the existingFeedzy_Rss_Feeds_Log::set_context()and clears it infinally; the original body moved unchanged torun_job_logic(). Every entry written during a run — including fetch-layer errors — is attributed automatically.init_single_feed()— a single broken feed URL used to import 0 items with no error logged (it returned early on unparseable feeds); it now logs the SimplePie error withfeed_url, matching the multi-feed path.Logs viewer — each entry gets an import badge (
Title (#ID)) and a feed-source badge, falling back to the legacyjob_id/sourcecontext keys; entries without attribution keys render exactly as before, and the raw JSON context stays visible.Note
No new translatable strings — the badges reuse existing labels, keeping the generated POT unchanged as the Translations Diff job requires.
import_titlein the logger context is reserved for job attribution; the post-title mapping template uses the separateimport_post_titlekey.Also in this PR
developmentmerge — brings in the e2e infra upgrade (dev: upgrade e2e infra, add copilot setup and expand test coverage #1288); the branch runs Playwright 1.62.0, wp-env 11.11.0 and e2e-test-utils-playwright 1.51.0, and the mergedtests/test-plugin-health.phpis updated for the class rename below.WordPress.org Plugin Check fixes (pre-existing, plugin-wide — the check fails every PR until resolved): direct-access
ABSPATHguards added to 26 PHP files;unlink()→wp_delete_file()(5 call sites), with the deliberate direct-filesystem fast paths (fclose()/readfile()in the guarded log tail/download) carryingphpcs:ignoreannotations matching the file's existingfopen()ones;chosen-sprite@2x.png→chosen-sprite-2x.png(special character in filename), CSS reference updated.Feedzy_Rss_Feeds_Util_SimplePie→Feedzy_Rss_Feeds_Util_Feed— the old filename false-matched Plugin Check's bundled-core-library rule; the class is renamed with the file so the autoloader's naming convention resolves it with no special-casing. Pro has no references to the old name.e2e stability — a test-only mu-plugin (
tests/e2e/mu-plugins/feedzy-e2e-youtube-feed-mock.php, mounted via the new.wp-env.jsonmu-plugins mapping) serves a canned YouTube channel feed throughpre_http_request, so the classic-block embed test no longer depends on live YouTube availability (GitHub runner IPs get throttled); the run-now AJAX wait allows 60s because a real import with image sideloads exceeds the 10s default.Import logging flow
flowchart LR A["run_now() /<br/>run_cron()"] --> B["New: run_job()<br/>sets logger context,<br/>clears in finally"]:::added B --> C["run_job_logic()<br/>(former run_job body)"] C --> D{Feed<br/>parses?} D -- Yes --> E[Import items] D -- No --> F["Changed: error logged<br/>with feed_url<br/>(was silent for single feeds)"]:::changed E --> G[JSONL log with context] F --> G G --> H["Changed: viewer shows<br/>import + feed badges,<br/>legacy-key fallback"]:::changed classDef added fill:#1a7f37,color:#fff,stroke:#116329,stroke-width:3px classDef changed fill:#9a6700,color:#fff,stroke:#5c3d00,stroke-width:3px,stroke-dasharray:6 3Data changes
New optional keys inside each JSONL log entry's
contextobject (file:wp-content/uploads/feedzy-logs/; written only while an import job runs; old entries are never rewritten):import_idrun_job()wrapperimport_titlerun_job()wrappersourcesourcemeta (URL list or category slug)run_job()wrapper; per-callfeed_urloverrides it for URL-specific entriesBefore → after:
{"level":"error","message":"..."}→{"level":"error","message":"...","context":{"import_id":12,"import_title":"My import","source":"https://…/feed.xml"}}QA instructions
https://example.com/nonexistent-feed.xml) — activate both, then click Run Now on each. Open WP Admin → Feedzy → Settings → Logs tab and filter by Error.Expect: each error entry carries a
Title (#ID)badge naming the failing import plus its feed URL — the healthy import is never blamed.Expect: info/debug entries carry the same import and feed badges as errors.
[feedzy-rss feeds="https://example.com/nonexistent-feed.xml"], view it on the front end, then reload WP Admin → Feedzy → Settings → Logs tab.Expect: the fetch error shows a feed-source badge but no import badge (no import job was involved).
Expect: old entries render as before (legacy
job_id/sourcekeys shown as badges where present, plain rendering otherwise).Check before Pull Request is ready:
Closes #1278.
🤖 Generated with Claude Code