Make WordPress Core

Opened 5 months ago

Last modified 5 months ago

#61987 new enhancement

Removed Unused Arguments From _wp_filter_build_unique_id Function

Reported by: wpdebuglog's profile wpdebuglog Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Plugins Keywords: has-patch has-unit-tests
Focuses: Cc:

Description

The function _wp_filter_build_unique_id($hook_name, $callback, $priority) has two unused arguments: $hook_name and $priority.
I believe these arguments are unnecessary.

Change History (9)

This ticket was mentioned in PR #7292 on WordPress/wordpress-develop by arshidkv12.


5 months ago
#1

  • Keywords has-patch has-unit-tests added

#2 @dd32
5 months ago

Changing the function syntax will unfortunately affect some plugins, as this isn't purely used by Core. For example, see the various results here: https://wpdirectory.net/search/01J6ZZP5FWDKVHHJY5R4GTJP27

Arguably, leaving it as-is is the safer option, even though it's @access private.

Note; the change was done via [46220] + #48074

#3 @peterwilsoncc
5 months ago

  • Component changed from General to Plugins

I agree with Dion (I was just searching for the same history he just posted).

If anything the most WordPress can do is rename the arguments $deprecated_1 and $deprecated_2

#4 @SergeyBiryukov
5 months ago

Hi there, welcome to WordPress Trac! Thanks for the ticket.

Note that these parameters are already marked as unused in the documentation, see [46801] / #47407.

Last edited 5 months ago by SergeyBiryukov (previous) (diff)

#5 follow-up: @jrf
5 months ago

I agree with @dd32 and @peterwilsoncc. While I kind of like Peter's suggestion for renaming the parameters, even though WP doesn't officially support named parameters, this could affect function calls from plugins which have decided to ignore that fact.

What about adding a default value of 0 for the $priority parameter though ? That would make the parameter optional and could allow for simplifying calls to the function by removing the need to pass one of the two deprecated/unused parameters.

#6 in reply to: ↑ 5 ; follow-up: @dd32
5 months ago

Replying to jrf:

What about adding a default value of 0 for the $priority parameter though ? That would make the parameter optional and could allow for simplifying calls to the function by removing the need to pass one of the two deprecated/unused parameters.

I'd go for 10 since that's the default priority elsewhere, but that feels like a reasonable middle-ground.

Although, it's such a minor change that doesn't really make the function nicer to use, since it's got an unused parameter first.. kinda feels like "what's the point in changing anything" :)

#7 in reply to: ↑ 6 @jrf
5 months ago

Replying to dd32:

Although, it's such a minor change that doesn't really make the function nicer to use, since it's got an unused parameter first.. kinda feels like "what's the point in changing anything" :)

Indeed. I'm fine with closing this ticket without action. More than anything, the original "ask" (changing the signature) should not be accepted.

#8 follow-up: @knutsp
5 months ago

Could a new function be created and used in core, and deprecate this one?

#9 in reply to: ↑ 8 @peterwilsoncc
5 months ago

Replying to knutsp:

Could a new function be created and used in core, and deprecate this one?

I don't think there is much point as the function is very low level. For the million or so sites running plugins making use of the function, it would add noise to their logs without any real gain.

I will keep this ticket open so a default can be added to the final unused argument to allow the function to be called without specifying it.

Note: See TracTickets for help on using tickets.