Skip to content

Docs: Require view config filter callbacks to return the container#12641

Closed
jorgefilipecosta wants to merge 1 commit into
WordPress:trunkfrom
jorgefilipecosta:fix/view-config-filter-return-docs
Closed

Docs: Require view config filter callbacks to return the container#12641
jorgefilipecosta wants to merge 1 commit into
WordPress:trunkfrom
jorgefilipecosta:fix/view-config-filter-return-docs

Conversation

@jorgefilipecosta

@jorgefilipecosta jorgefilipecosta commented Jul 22, 2026

Copy link
Copy Markdown
Member

What

Corrects the get_entity_view_config_{$kind}_{$name} filter docblock: callbacks must return the container they receive. Also fixes a doubled "the" in the same paragraph.

Follow-up to #12638.

Why

The docblock told callbacks the container is mutated in place, so there is "no need to return it; any returned value is ignored". Only the final return is discarded: as with any filter, WP_Hook::apply_filters() passes each callback's return value to the next callback as $data, so a callback that follows that advice hands null to every callback hooked at a later priority, which fatals the moment it calls a method on it (Call to a member function merge() on null). A single callback never surfaces this, so it would only show up in the wild once two plugins hook the same filter.

Docs-only; the dispatch is unchanged. The new text states the standard filter rule and points out that the write methods return the container, so a callback can end with return $data->merge( $patch, $version );. The existing filter tests already register callbacks that return the container.

AI usage disclosure

AI assistance: Yes
Tool(s): Claude Code
Model(s): Opus
Used for: PR description and code comment. Manually verified and tuned.

Trac ticket: https://core.trac.wordpress.org/ticket/65577

The `get_entity_view_config_{$kind}_{$name}` filter docblock advised
callbacks not to return the container, but as with any filter each
callback's return value is passed to the next callback, so a callback
that returns nothing hands `null` to callbacks hooked at later
priorities. Document the standard filter contract instead, noting that
the write methods return the container for chaining. Also fixes a
doubled word.

See #65577.
Copilot AI review requested due to automatic review settings July 22, 2026 12:47
@github-actions

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props jorgefilipecosta.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the inline documentation for the get_entity_view_config_{$kind}_{$name} filter to reflect WordPress’s standard filter contract: each callback must return the (possibly mutated) value so subsequent callbacks receive the expected container object, preventing null from being passed down the filter chain.

Changes:

  • Corrects the filter docblock to require callbacks to return the WP_View_Config_Data container they receive (since each return value is forwarded to the next callback).
  • Adds a concrete example showing callbacks can return the container directly from a write method (e.g. return $data->merge( $patch, $version );).
  • Fixes a duplicated “the” in the same paragraph.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions

Copy link
Copy Markdown

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

@github-actions

Copy link
Copy Markdown

A commit was made that fixes the Trac ticket referenced in the description of this pull request.

SVN changeset: 62833
GitHub commit: b0e62d8

This PR will be closed, but please confirm the accuracy of this and reopen if there is more work to be done.

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.

3 participants