Skip to content

Build/Test Tools: Remove redundant $accepted_args from remove_filter()/remove_action() calls - #12835

Open
Soean wants to merge 1 commit into
WordPress:trunkfrom
Soean:fix/remove-filter-redundant-accepted-args
Open

Build/Test Tools: Remove redundant $accepted_args from remove_filter()/remove_action() calls#12835
Soean wants to merge 1 commit into
WordPress:trunkfrom
Soean:fix/remove-filter-redundant-accepted-args

Conversation

@Soean

@Soean Soean commented Aug 4, 2026

Copy link
Copy Markdown
Member

Description

remove_filter( $hook_name, $callback, $priority = 10 ) and remove_action( $hook_name, $callback, $priority = 10 ) take three parameters. A number of places in the PHPUnit test suite pass a fourth one, copied over from the matching add_filter()/add_action() call:

add_filter( 'domain_exists', array( $this, 'domain_exists_cb' ), 10, 4 );
$exists = domain_exists( 'foo', 'bar' );
remove_filter( 'domain_exists', array( $this, 'domain_exists_cb' ), 10, 4 );

The fourth argument is silently ignored by PHP, but it is misleading: it suggests $accepted_args is part of the callback identity used to locate and unhook the callback, which it is not. Only the hook name, the callback and the priority are relevant.

This removes the superfluous argument throughout the test suite. Where the priority was the default 10, the now-redundant priority argument is dropped as well:

remove_filter( 'domain_exists', array( $this, 'domain_exists_cb' ) );

Non-default priorities are kept, since remove_filter() only finds a callback under the exact priority it was registered with:

remove_filter( 'pre_do_shortcode_tag', array( $this, 'filter_pre_do_shortcode_tag_attr' ), 12 );

No occurrences remain in src/, so this is a test-only change with no behavioural difference.

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


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

…er()`/`remove_action()` calls.

`remove_filter()` and `remove_action()` only accept `$hook_name`, `$callback` and `$priority`. A fourth argument mirroring the `$accepted_args` of the corresponding `add_filter()`/`add_action()` call is silently ignored and wrongly suggests that the number of accepted arguments is part of the callback identity.
This removes the superfluous fourth argument throughout the PHPUnit test suite, and also drops the explicit default priority of `10` where it is not needed. Non-default priorities are kept.
@github-actions

github-actions Bot commented Aug 4, 2026

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 soean.

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

@github-actions

github-actions Bot commented Aug 4, 2026

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.

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