Skip to content

Read a missing query inherit key as not inherited - #58

Merged
roborourke merged 3 commits into
mainfrom
claude/bug-validation-fixes-07a61k-issue-15
Sep 2, 2026
Merged

Read a missing query inherit key as not inherited#58
roborourke merged 3 commits into
mainfrom
claude/bug-validation-fixes-07a61k-issue-15

Conversation

@roborourke

@roborourke roborourke commented Sep 2, 2026

Copy link
Copy Markdown
Collaborator

Fixes #15.

Reproduced

A query loop whose query attribute names an object without inherit (hand-written pattern markup, third-party query blocks — the object attribute is used as authored, so the block type's default is not merged in) renders the post type filter twice per request, and each render raises the notice:

PHP Warning:  Undefined array key "inherit" in .../build/post-type/render.php on line 13
PHP Warning:  Undefined array key "inherit" in .../build/post-type/render.php on line 32

Verified against WordPress 6.8.8 and 7.0.4 with Twenty Twenty-Five. The taxonomy filter named in the issue was fixed earlier; the same read survived in the post type filter.

Changes

  • src/post-type/render.php reads inherit through empty() once, into $inherit, and reuses it for the inherited post type fill-in further down.
  • tests/mu-plugins/register-test-content.php records PHP notices raised from this plugin's own files and prints them as <!-- qf-php-error: … -->, followed by a qf-php-errors-checked marker. A page's cleanliness is then assertable without depending on the environment's display_errors — a warning does not reach the response under every SAPI.
  • tests/seed.php adds fixture page 4, /no-inherit-context/: both filters in a query loop whose context omits inherit.
  • tests/e2e/query-context.spec.js asserts that page renders no plugin notice and that the filters still narrow the loop.

Verification

The new spec fails on main (qf-php-error: Undefined array key "inherit" in post-type/render.php:13) and passes with the fix. Full suite: 22 passed on WP 6.8.8 and 7.0.4. composer phpcs clean on the changed PHP.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Lj871x28S1DXjoVm7AB4k5


Generated by Claude Code

Open WordPress Playground Preview

The post type filter reads `$block->context['query']['inherit']` directly.
The query block's own attribute default carries the key, but markup that
names a `query` object without it — hand written patterns, third party
query blocks — reaches render with the key absent, and every render of the
filter raises "Undefined array key \"inherit\"" twice.

Read it through empty(), as the taxonomy filter already does, and reuse the
result for the inherited post type fill-in below.

The test mu-plugin now records notices raised from this plugin's own files
and prints them into the page, so a spec can assert a page rendered cleanly
without depending on how the environment displays errors. Fixture page 4
carries a query loop whose context omits `inherit`.

Fixes #15

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Lj871x28S1DXjoVm7AB4k5
@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown

Playwright — PHP 8.3 / WP latest

passed  25 passed

Details

stats  25 tests across 6 suites
duration  32.6 seconds
commit  af0aaf5

@roborourke
roborourke marked this pull request as ready for review September 2, 2026 11:39
…-fixes-07a61k-issue-15

# Conflicts:
#	tests/e2e/README.md
#	tests/seed.php
github-actions Bot added a commit that referenced this pull request Sep 2, 2026
github-actions Bot added a commit that referenced this pull request Sep 2, 2026
@roborourke
roborourke merged commit 8b9fb86 into main Sep 2, 2026
6 checks passed
@roborourke
roborourke deleted the claude/bug-validation-fixes-07a61k-issue-15 branch September 2, 2026 13:54
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.

Warning: Undefined array key “inherit” in /wp-content/plugins/query-filter/build/taxonomy/render.php on line 10

2 participants