Changes between Initial Version and Version 1 of Ticket #44212, comment 1
- Timestamp:
- 05/24/2018 03:12:41 PM (5 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #44212, comment 1
initial v1 1 1 In [attachment:44212.2.patch] the function `wp_parse_list()` is introduced and is used by `wp_parse_id_list()` and `wp_parse_slug_list()`. 2 2 3 With this function it now removes the empty values returned by `preg_split()`. You can also remove all the values that equal to false by setting the `$format` parameter to 'filter_false'. We could use this filter for `wp_parse_id_list()` as IDs are not supposed to have a value of 0. I've left it as is for back compatibility.3 With this function it now removes the empty values returned by `preg_split()`. You can also remove all the values that equal to false by setting the `$format` parameter to `filter_false`. We could use this filter for `wp_parse_id_list()` as IDs are not supposed to have a value of 0. I've left it as is for back compatibility. 4 4 5 The other instances where `preg_split()` is used with the same regex should get their own ticket for replacing it with `wp_parse_list()`. This is because sometimes it's expected to have an empty value for empty strings. 5 == Empty strings == 6 There are differences between what is returned for `preg_split()` (without the `PREG_SPLIT_NO_EMPTY`) flag and the `wp_parse_id_list()` function if you use it with an empty string 7 6 8 {{{ 9 $array = preg_split( '/[\s,]+/', '' ); 10 11 // non empty array 7 12 array( 8 13 0 => '' 9 14 ) 15 16 $array = wp_parse_list(''); 17 18 // empty array 19 array( 20 21 ) 10 22 }}} 23 24 New tickets should be created for the other instances where `preg_split()` is used (with the same regex) that expect an empty array (and are now iterating over it).