Skip to content

fix: render query templates included during template_redirect, and run it after boot - #420

Merged
ogorzalka merged 2 commits into
developfrom
fix/issue-419
Oct 7, 2026
Merged

ogorzalka merged 2 commits into
developfrom
fix/issue-419

Conversation

@ogorzalka

Copy link
Copy Markdown
Member

Closes #419. Thanks @Loubal70 for the thorough report and the patch it starts from.

Layer 1 — a Blade file included by PHP. Each {type}_template filter (404_template…) hands back a loader that renders the view (the same makeLoader() as WooCommerce templates), only while template_redirect runs. Outside it the path is untouched: the FrontendController needs the Blade path, and WordPress's own template loader still meets the raw-output guard. New MakeTemplateIncludableUseCase (Application layer); the WordPress condition stays in WordPressTemplateHierarchyFilter::includableTemplate().

Layer 2 — template_redirect before the providers booted. wp() stays where it is; template_redirect, the robots / favicon / feed / trackback answers and pollora_loaded run in App::booted(), under the same WordPress error handling. Requests on WordPress's own entry points fire pollora_loaded at once, as before.

Trackbacks answered 500 (wp-trackback.php required from a method loads WordPress again): the branch declares global $wp, $wpdb, $posts.

Tests

  • Pest: the use case, the filter (during / after template_redirect), the filter registration, and runWp() deferring template_redirect until boot (fails on the old code). 1821 passed; PHPStan (macro call baselined like WooCommerce's), Rector (test excluded from ServerVariableToRequestFacadeRector, like its sibling), Pint clean.
  • E2E: the e2e-features fixture plugin answers ?e2e-template-redirect like WooCommerce's Review Order page; the spec checks the 404 renders with the layout, and that a trackback is answered and stored. Both fail on the old code, pass with the fix (pollora-test, Chromium).

Checked by HTTP on pollora-test (apiary + WooCommerce 10.9)

Same 16 URLs with and without the fix — home, robots.txt, feeds, favicon, Pollora's 404, /cms/ (302 home), ?p=1, shop, cart, account, search, product search redirect, posts, pages: identical. Only the reproduction changes (Blade source → rendered 404 page with header and footer), and the trackback (500 → 200, stored).

@ogorzalka
ogorzalka merged commit 6b2e555 into develop Oct 7, 2026
11 checks passed
@ogorzalka
ogorzalka deleted the fix/issue-419 branch October 7, 2026 08:01
@ogorzalka ogorzalka mentioned this pull request Oct 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant