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

WordPress Trac noreply at wordpress.org
Fri Sep 25 00:02:54 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 needs-dev-note  |     Focuses:  coding-standards
-------------------------------------------+-------------------------------

Comment (by SergeyBiryukov):

 In [changeset:"49043" 49043]:
 {{{
 #!CommitTicketReference repository="" revision="49043"
 Code Modernization: Correct the check for `parent` argument in
 `wp_insert_term()` and `wp_update_term()`.

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

 In particular, checking if a non-empty, non-numeric string is greater than
 zero in PHP 8 evaluates to `true`, not `false`.

 For `wp_insert_term()`, this resulted in a "Parent term does not exist"
 error for a non-numeric string, instead of discarding the value.

 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 [29196], [29830], [29867].

 See #50913.
 }}}

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


More information about the wp-trac mailing list