Make WordPress Core

Changes between Version 6 and Version 7 of Ticket #57923, comment 11


Ignore:
Timestamp:
03/15/2023 12:40:20 PM (2 years ago)
Author:
costdev
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #57923, comment 11

    v6 v7  
    11111. Implicitly accept `null`, by:
    1212  a. Adding `null !== $terms` to the condition [https://github.com/WordPress/WordPress/blob/1bf93a87a449a9476d1efd93a0452d7d6ceb3808/wp-includes/taxonomy.php#L2728-L2730 here].
    13     i. This would avoid the deprecation notice, as the `foreach()` uses `(array) $terms`, converting `null` to `array()` just for the `foreach()` loop.
     13    i. This would avoid the deprecation notice, as the `foreach()` uses `(array)
     14    ii. This would prevent changing the value of `$terms` passed by the `set_object_terms` action from `array( null )` to `array()`.
    14152. Or, explicitly accept `null`, by:
    1516  a. Adding `null` to the list of types for `$terms`.
    1617  b. Adding `if ( empty( $terms ) ) { $terms = array(); }` before line 2728.
    1718    i. This would cover more values than `null` but, as far I know, none of those values are valid Term IDs/slugs, and it would be consistent with the current documentation: "Passing an empty value will remove all related terms."
     19    ii. This would change the value of `$terms` passed by the `set_object_terms` action from `array( null )` to `array()`.
    18203. Or, a mixture of both:
    1921  a. Adding `null` to the list of types for `$terms`.