Mantis - Quercus
Viewing Issue Advanced Details
4929 major always 01-24-12 06:39 06-21-12 01:23
jgilje  
nam  
normal  
closed 4.0.14  
unable to reproduce  
none    
none  
0004929: Array is passed as reference, even though function is defined as pass-by-value
Using the latest version of wordpress, I had trouble using the page-editor. On wp-admin/edit.php?post_type=page no edit links appear. I narrowed the bug down to the global variable $wp_post_types getting corrupted by the callstack starting at

wp-admin/includes/post.php - line 852 - call to get_post_types();
wp-includes/post.php - line 854 - call to wp_filter_object_list();
wp-includes/functions.php - 3228 - call to wp_list_pluck();
wp-includes/functions.php - 3286 - definition of wp_list_pluck();

After the call to wp_list_pluck(), $wp_post_types is corrupted. However, if changing the function wp_list_pluck() to create a copy of its $list parameter as follows

function wp_list_pluck( $list, $field ) {
    $ret = array();
    foreach ( $list as $key => $value ) {
        if ( is_object( $value ) )
            $ret[ $key ] = $value->$field;
        else
            $ret[ $key ] = $value[ $field ];
    }

    return $ret;
}

it works perfectly. To me, this seems as the $list variable passed to wp_list_pluck() is assigned by reference and not by value through the callstack coming from get_post_types() in wp-includes/post.php - even though the functions involved does not specify pass-by-reference.
 diff.txt [^] (569 bytes) 01-24-12 06:39

Notes
(0005918)
nam   
06-21-12 01:23   
Unable to reproduce on 4.0.29. Tested wordpress-3.3.1. I am seeing edit links for the edit.php page.