[wp-trac] [WordPress Trac] #49219: feed.php calls apply_filters with too many arguments
WordPress Trac
noreply at wordpress.org
Fri Jan 17 15:40:26 UTC 2020
#49219: feed.php calls apply_filters with too many arguments
--------------------------+----------------------
Reporter: bret.miller | Owner: (none)
Type: defect (bug) | Status: closed
Priority: normal | Milestone:
Component: Feeds | Version: 5.3.2
Severity: normal | Resolution: invalid
Keywords: | Focuses:
--------------------------+----------------------
Changes (by SergeyBiryukov):
* status: new => closed
* resolution: => invalid
* milestone: Awaiting Review =>
Comment:
Hi there, welcome to WordPress Trac! Thanks for the ticket.
There are 1200+ instances of passing more than two arguments to
`apply_filters()` in WordPress core.
While the `WP_Hook::apply_filters()` method indeed only accepts two
parameters, the [source:tags/5.3/src/wp-
includes/plugin.php?marks=151,156,160,169,178,184#L143 apply_filters()]
function accepts any number of parameters to pass to the callback function
using `func_get_args()`.
If you want your callback function to receive these additional parameters,
you have to specify the number of arguments as the 4th parameter in your
`add_filter()` call:
{{{
add_filter( 'get_bloginfo_rss', 'my_function', 10, 2 );
}}}
There is no bug here, this code works as intended.
Related: #33891
--
Ticket URL: <https://core.trac.wordpress.org/ticket/49219#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list