Make WordPress Core

Opened 7 years ago

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

7 years ago

#1 @scribu
7 years ago

Context: #14084

#2 @scribu
7 years ago

  • Keywords needs-refresh added

#3 @mark8barnes
7 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?

#4 @SergeyBiryukov
7 years ago

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

#5 @scribu
7 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 7 years ago by scribu (previous) (diff)

#6 @scribu
7 years ago

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