[wp-trac] [WordPress Trac] #53474: Improve Walker compatibility with PHP8

WordPress Trac noreply at wordpress.org
Tue Jun 22 19:07:41 UTC 2021


#53474: Improve Walker compatibility with PHP8
----------------------------+-----------------------------
 Reporter:  sunxiyuan       |       Owner:  SergeyBiryukov
     Type:  defect (bug)    |      Status:  closed
 Priority:  normal          |   Milestone:  5.8
Component:  General         |     Version:  trunk
 Severity:  major           |  Resolution:  fixed
 Keywords:  has-patch php8  |     Focuses:
----------------------------+-----------------------------
Changes (by SergeyBiryukov):

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


Comment:

 In [changeset:"51204" 51204]:
 {{{
 #!CommitTicketReference repository="" revision="51204"
 Code Modernization: Use a consistent check for parent items in
 `WP_Walker`.

 This affects the `::walk()`, `::paged_walk()`, and
 `::get_number_of_root_elements()` methods.

 PHP 8 changes the way string to number comparisons are performed:
 https://wiki.php.net/rfc/string_to_number_comparison

 In particular, checking if an empty string is equal to zero in PHP 8
 evaluates to `false`, not `true`.

 For the `WP_Walker` class, this resulted in an incorrect handling of
 parent items in a few methods.

 By explicitly checking for an `empty()` value instead, we make sure the
 check works as expected in PHP 8 and earlier versions.

 Follow-up to [35876], [48960], [49043], [49076].

 Props sunxiyuan, aristath, SergeyBiryukov.
 Fixes #53474.
 }}}

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


More information about the wp-trac mailing list