[wp-trac] [WordPress Trac] #57923: Deprecated notice fired by wp_set_object_terms() with PHP 8.1
WordPress Trac
noreply at wordpress.org
Tue Mar 14 19:10:35 UTC 2023
#57923: Deprecated notice fired by wp_set_object_terms() with PHP 8.1
--------------------------+-----------------------------
Reporter: Chouby | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Taxonomy | Version:
Severity: normal | Keywords: php81
Focuses: |
--------------------------+-----------------------------
It is [https://github.com/Yoast/duplicate-post/pull/293 common practice]
to pass `null` as second parameter of `wp_set_object_terms()` to remove
all terms.
In such case, PHP throws this notice:
{{{
Deprecated: trim(): Passing null to parameter #1 ($string) of type string
is deprecated in /app/polylang/tmp/wordpress/wp-includes/taxonomy.php on
line 2751
}}}
Of course, this can be fixed by replacing `null` by `array()` as second
param but I wonder if WordPress should not protect itself from this notice
by replacing any empty `$terms` by `array()`
[https://github.com/WordPress/WordPress/blob/1bf93a87a449a9476d1efd93a0452d7d6ceb3808
/wp-includes/taxonomy.php#L2728-L2730 before singular values are converted
to an array].
--
Ticket URL: <https://core.trac.wordpress.org/ticket/57923>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list