WordPress.org

Make WordPress Core

Opened 5 weeks ago

Last modified 5 weeks ago

#53218 new enhancement

Make apply_filters() variadic

Reported by: johnbillion Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version: 5.3
Component: Plugins Keywords: has-patch
Focuses: Cc:

Description

Previously in #47678 most functions in core that call func_get_args() were converted to variadic functions. One exception is apply_filters() which was left as-is due to a concern about filters which pass (and expect) a value by reference:

WP_Hooks::apply_filters() can not be simplified further as - even within WP Core -, there are filter functions which expect to receive the $value to be filtered by reference.

Ref: https://core.trac.wordpress.org/ticket/47678#comment:31

It does seem however that this function can be made variadic by adding an additional parameter after $value instead of making $value variadic. The existing tests pass with this change, but the test coverage might not be sufficient.

There are two potential outcomes to this ticket:

  1. Make apply_filters() variadic by adding an additional ...$args parameter, leaving the existing $value parameter alone, or
  2. Add tests which demonstrate why this cannot be done

Change History (1)

This ticket was mentioned in PR #1259 on WordPress/wordpress-develop by johnbillion.


5 weeks ago

  • Keywords has-patch added; needs-patch removed
Note: See TracTickets for help on using tickets.