[wp-trac] [WordPress Trac] #50913: PHP 8.0: various compatibility fixes

WordPress Trac noreply at wordpress.org
Wed Sep 9 02:33:37 UTC 2020


#50913: PHP 8.0: various compatibility fixes
----------------------------+-------------------------------
 Reporter:  jrf             |       Owner:  SergeyBiryukov
     Type:  task (blessed)  |      Status:  reviewing
 Priority:  normal          |   Milestone:  5.6
Component:  General         |     Version:
 Severity:  normal          |  Resolution:
 Keywords:  php8 has-patch  |     Focuses:  coding-standards
----------------------------+-------------------------------

Comment (by SergeyBiryukov):

 In [changeset:"48960" 48960]:
 {{{
 #!CommitTicketReference repository="" revision="48960"
 Code Modernization: Correct the check for negative post IDs in
 `WP_Query::parse_query()` to work as expected on PHP 8.

 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 less than zero in PHP 8
 evaluates to `true`, not `false`.

 For `WP_Query`, this resulted in unintentionally returning a 404 error for
 most of front-end requests, instead of the relevant content.

 By explicitly casting the value to `int`, we make sure to compare both
 values as numbers, rather than a string and a number.

 Follow-up to [38288].

 Props trepmal.
 See #50913.
 }}}

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


More information about the wp-trac mailing list