Make WordPress Core

Opened 5 years ago

Closed 5 years ago

#48123 closed defect (bug) (fixed)

Remove `$accepted_args` from hooks, whose callbacks do not have any arguments

Reported by: itowhid06's profile itowhid06 Owned by: sergeybiryukov's profile SergeyBiryukov
Milestone: 5.3 Priority: low
Severity: normal Version:
Component: General Keywords: has-patch
Focuses: coding-standards Cc:

Description

Some callable functions do not accept any arguments, but they have 1 as accepted argument numbers in default-filters.php. This patch removes them.

Attachments (2)

48123.diff (1.4 KB) - added by itowhid06 5 years ago.
48123.1.diff (892 bytes) - added by itowhid06 5 years ago.

Download all attachments as: .zip

Change History (11)

@itowhid06
5 years ago

#2 @johnbillion
5 years ago

  • Keywords needs-refresh added
  • Milestone changed from Awaiting Review to Future Release
  • Priority changed from normal to low
  • Version trunk deleted

Thanks for the patch @itowhid06 . The default value for the $accepted_args parameter of add_action() is 1, so this change doesn't correct anything.

Can you update the patch to change the parameter to 0 where appropriate?

#3 @itowhid06
5 years ago

Thanks for the suggestion @johnbillion . I've updated the patch. Is it OK now?

@itowhid06
5 years ago

#4 @jrf
5 years ago

  • Keywords needs-refresh removed

LGTM

#5 follow-up: @jrf
5 years ago

Confirmed that none of these three functions take arguments:

Relevant hook calls:

I've not been able to find a WP native do_action() call with the hook name do_pings, though that is outside the scope of this ticket.

#6 @itowhid06
5 years ago

  • Focuses coding-standards added

#7 in reply to: ↑ 5 @SergeyBiryukov
5 years ago

Replying to jrf:

I've not been able to find a WP native do_action() call with the hook name do_pings, though that is outside the scope of this ticket.

It's an event scheduled in _publish_post_hook().

#8 @SergeyBiryukov
5 years ago

  • Milestone changed from Future Release to 5.3

#9 @SergeyBiryukov
5 years ago

  • Owner set to SergeyBiryukov
  • Resolution set to fixed
  • Status changed from new to closed

In 46432:

Coding Standards: Correct the number of accepted arguments in add_action() calls in wp-includes/default-filters.php for functions that don't accept any arguments.

Props itowhid06, johnbillion, jrf.
Fixes #48123.

Note: See TracTickets for help on using tickets.