Changes between Version 6 and Version 7 of Ticket #57923, comment 11
- Timestamp:
- 03/15/2023 12:40:20 PM (2 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #57923, comment 11
v6 v7 11 11 1. Implicitly accept `null`, by: 12 12 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()`. 14 15 2. Or, explicitly accept `null`, by: 15 16 a. Adding `null` to the list of types for `$terms`. 16 17 b. Adding `if ( empty( $terms ) ) { $terms = array(); }` before line 2728. 17 18 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()`. 18 20 3. Or, a mixture of both: 19 21 a. Adding `null` to the list of types for `$terms`.