Make WordPress Core

Opened 4 years ago

Last modified 3 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)

@scribu4 years ago

comment:1 @scribu4 years ago

Context: #14084

comment:2 @scribu4 years ago

  • Keywords needs-refresh added

comment:3 @mark8barnes4 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?

@SergeyBiryukov4 years ago

comment:4 @SergeyBiryukov4 years ago

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

comment:5 @scribu4 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 4 years ago by scribu (previous) (diff)

comment:6 @scribu4 years ago

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