WordPress.org

Make WordPress Core

Opened 3 years ago

Last modified 2 years ago

#16137 closed defect (bug)

wp_list_filter() is inexact when dealing with nested arrays — at Version 6

Reported by: scribu Owned by:
Milestone: 3.3 Priority: normal
Severity: normal Version:
Component: General Keywords: has-patch
Focuses: Cc:

Description (last modified by scribu)

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.

Change History (8)

scribu3 years ago

comment:1 scribu3 years ago

Context: #14084

comment:2 scribu3 years ago

  • Keywords needs-refresh added

comment:3 mark8barnes3 years ago

  • Cc mark@… added

I just came across this problem. The bug breaks get_taxonomies( $args, $output, $operator ) when $args = array('object_type' => array($custom_post_type)), but the patch fixes it. Can we get this in 3.2?

SergeyBiryukov3 years ago

comment:4 SergeyBiryukov3 years ago

  • Keywords needs-refresh 3.2-early removed
  • Milestone changed from Future Release to 3.3

comment:5 scribu3 years ago

While we're at it, we should use get_object_vars() instead of casting to array, in case the object has non-public properties, which we don't care about.

Last edited 3 years ago by scribu (previous) (diff)

comment:6 scribu3 years ago

  • Description modified (diff)
Note: See TracTickets for help on using tickets.