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

WordPress Trac noreply at wordpress.org
Mon Jun 21 21:27:03 UTC 2021


#53474: Improve Walker compatibility with PHP8
--------------------------+-----------------------------
 Reporter:  sunxiyuan     |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  General       |    Version:  trunk
 Severity:  major         |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 PHP 8 introduced a new numeric and string comparison mechanism
 For the following code:

 {{{#!php
 <?php
 0 == '';
 }}}

 True under PHP 7 and False under PHP 8.

 There is the following statement in line 345 of the Walker class (wp-
 includes/class-wp-walker.php):

 {{{#!php
 <?php
 if ( 0 == $e->$parent_field ) {
 }}}

 If $e->$parent_field is an empty string, the judgment result of the
 statement in PHP 7 and PHP 8 will be inconsistent.

 The question broke the reply order of my bbPress forum.

 The offending code should be changed to:

 {{{#!php
 <?php
 if ( 0 == (int) $e->$parent_field ) {
 }}}

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


More information about the wp-trac mailing list