[wp-trac] [WordPress Trac] #16137: wp_list_filter() is inexact when dealing with nested arrays

WordPress Trac wp-trac at lists.automattic.com
Thu Aug 4 20:43:31 UTC 2011


#16137: wp_list_filter() is inexact when dealing with nested arrays
--------------------------+------------------
 Reporter:  scribu        |       Owner:
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  3.3
Component:  General       |     Version:
 Severity:  normal        |  Resolution:
 Keywords:  has-patch     |
--------------------------+------------------
Description changed by scribu:

Old description:

> To reproduce:
>
> {{{
> add_action('init', 'test_admin_notices', 11);
> function test_admin_notices() {
>     global $wp_taxonomies;
>     print_r( wp_filter_object_list( array_values( $wp_taxonomies ),
> array( 'object_type' => array( 'post' ) ), 'and', 'object_type' ) );
> }
> }}}
>
> Doing a manual loop instead of using array_intersect_assoc() fixes the
> problem.

New description:

 To reproduce:

 {{{
 add_action('init', 'test_admin_notices', 11);
 function test_admin_notices() {
     global $wp_taxonomies;
     print_r( wp_filter_object_list( array_values( $wp_taxonomies ), array(
 'object_type' => array( 'post' ) ), 'and', 'object_type' ) );
 }
 }}}

 This is because array_intersect_assoc() does a strict comparison:
 {{{(string) $elem1 === (string) $elem2}}}

 Using a manual loop fixes the problem.

--

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/16137#comment:6>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list