[wp-trac] [WordPress Trac] #14881: do_action should not pass empty string by default

WordPress Trac noreply at wordpress.org
Sun May 31 05:23:05 UTC 2020


#14881: do_action should not pass empty string by default
--------------------------+----------------------
 Reporter:  nacin         |       Owner:  (none)
     Type:  defect (bug)  |      Status:  closed
 Priority:  normal        |   Milestone:
Component:  Plugins       |     Version:
 Severity:  normal        |  Resolution:  wontfix
 Keywords:  has-patch     |     Focuses:
--------------------------+----------------------

Comment (by wbeaumo):

 I just want to note that this bug has serious implications if your
 callback has a type declaration other than `string` for the first
 argument. You may argue that using type declarations in hook callbacks is
 counterproductive, but I don't know. We've had type hinting for classes in
 PHP for nearly 16 years, and type declarations for classes and built-in
 types for over 4 years. There are some of us who feel it's silly to not be
 able to use type declarations everywhere that's possible because of one
 stupid WordPress bug that's been around forever. Like, every time I write
 a callback I have to go through a mental checklist: "Is this for an
 action? Will it be called with just `do_action()` (as opposed to
 `do_action_ref_array()`)? Do I want the first param to be optional? Do I
 want it to be a type other than string? If all of the above, don't put a
 type declaration."

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/14881#comment:14>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list