Build/Test Tools: Remove redundant $accepted_args from remove_filter()/remove_action() calls - #12835
Build/Test Tools: Remove redundant $accepted_args from remove_filter()/remove_action() calls#12835Soean wants to merge 1 commit into
Conversation
…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.
|
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 Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Test using WordPress PlaygroundThe 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
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
Description
remove_filter( $hook_name, $callback, $priority = 10 )andremove_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 matchingadd_filter()/add_action()call:The fourth argument is silently ignored by PHP, but it is misleading: it suggests
$accepted_argsis 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:Non-default priorities are kept, since
remove_filter()only finds a callback under the exact priority it was registered with: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.