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

WordPress Trac noreply at wordpress.org
Tue Jun 22 19:06:14 UTC 2021


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

Comment (by SergeyBiryukov):

 Hi there, welcome to WordPress Trac! Thanks for the ticket and the patch.

 I think we can use an `empty()` check here, for consistency with the
 change to the `::walk()` method in [35876].

 There are three similar instances of these checks in a few methods:
 * `WP_Walker::walk()`
 * `WP_Walker::paged_walk()`
 * `WP_Walker::get_number_of_root_elements()`

 It looks like [35876] only fixed the first instance because the Menus
 screen only used the `::walk()` method, and the other two methods can
 currently still throw a PHP notice if a non-existing property is checked.
 So using `empty()` in all the three places would fix that in the other two
 methods too, as well as the issue reported here.

 I'll commit the change shortly, which also includes a unit test @aristath
 and I worked on.

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


More information about the wp-trac mailing list