[wp-trac] [WordPress Trac] #42918: Replace intval(), strval(), ... function calls with type casts

WordPress Trac noreply at wordpress.org
Fri Oct 9 10:58:14 UTC 2020


#42918: Replace intval(), strval(), ... function calls with type casts
-------------------------+-----------------------------
 Reporter:  ayeshrajans  |       Owner:  SergeyBiryukov
     Type:  enhancement  |      Status:  reopened
 Priority:  normal       |   Milestone:  5.6
Component:  General      |     Version:
 Severity:  normal       |  Resolution:
 Keywords:  has-patch    |     Focuses:  performance
-------------------------+-----------------------------
Changes (by SergeyBiryukov):

 * status:  closed => reopened
 * resolution:  fixed =>


Comment:

 Replying to [comment:10 johnjamesjacoby]:
 > The flaw in r49108 is in `add_menu_page()`:
 >
 > {{{
 > $menu[ "$position" ] = $new_menu;
 > }}}
 > ...was changed to use...
 > {{{
 > $menu[ $position ] = $new_menu;
 > }}}
 >
 > Here specifically:
 https://core.trac.wordpress.org/changeset/49108/trunk/src/wp-
 admin/includes/plugin.php
 >
 > PHP doesn't allow floats to be array keys, but it will allow strings to
 be, and WordPress is (perhaps unintentionally) smart enough to continue to
 order ints and strings-with-float-contents in the correct numerical
 sequence.

 Good catch, thanks!

 I only tested this with integers and numeric strings representing an
 integer, which produced the same results, as also described in this Stack
 Overflow thread: [https://stackoverflow.com/questions/4100488/a-numeric-
 string-as-array-key-in-php A numeric string as array key]. But I forgot
 about floats :)

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


More information about the wp-trac mailing list