Mantis Bugtracker
  

Viewing Issue Advanced Details Jump to Notes ] View Simple ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0004620 [Quercus] minor always 06-16-11 08:56 03-12-13 12:22
Reporter thr View Status public  
Assigned To nam
Priority normal Resolution unable to reproduce Platform
Status closed   OS
Projection none   OS Version
ETA none Fixed in Version Product Version 4.0.14
  Product Build
Summary 0004620: Quercus passes 'by value object' as 'reference'
Description Setting up Wordpress 3.1.3 on Quercus after making some quirks to get it run (Issue 0004568 and Issue 0004612) I get it working. Only if I signed in as admin and Under the menu Item where all articels are listed, I found a difference to a 'normal' php wordpress installation. All the links below the artikel list, which will allow you to edit, delete, etc, the articels, all my links where gone, like I do not have permission to edit.

Investigating the problem I found that Wordpress is using a function called 'wp_list_pluck' to reduce a big array of article-type definitions to a single value.

Thru some calls Wordpress passed the object $wp_post_types to this function.
This function then returns one field out of this object.
As this list is assigning a new value to one of the function parameters and returning it to the callee, I found after thre calls the original $wp_post_types was modfied/damaged.
As php is passing the object by value, this should not be possible. Under some circumstances Quercus seems to pass this object as reference.

To fix this, I changed the funtion in Wordpress to use a new variable to return the result instead of the function parameter.

Unfortunately I could not simulate the behaviour in a simple test script. But anyway I might want to have a look to understand the principle problem ...
 but there must be happening more in wordpress to cause this .....
Steps To Reproduce
Additional Information
/**
 * Pluck a certain field out of each object in a list
 *
 * @since 3.1.0
 *
 * @param array $list A list of objects or arrays
 * @param int|string $field A field from the object to place instead of the entire object
 * @return array
 */
function wp_list_pluck( $list, $field ) {
    foreach ( $list as $key => $value ) {
        $value = (array) $value;
        $list[ $key ] = $value[ $field ];
    }

    return $list;
}

CHANEGED To:

function wp_list_pluck( $list, $field ) {
    foreach ( $list as $key => $value ) {
        $value = (array) $value;
        $new_list[ $key ] = $value[ $field ];
    }

    return $new_list;
}
Attached Files  test_array_ref.php [^] (11,500 bytes) 06-16-11 08:56

- Relationships

- Notes
(0005684)
krystian
01-30-12 11:35

I can also confirm it is still the case in Resin 4.0.24
 
(0006130)
nam
12-30-12 00:13

Unable to reproduce in 4.0.33. Tried wordpress-3.1.3, wordpress-3.5, and your attached script.

We did fix a few value-vs-reference issues starting over the course of the last 6 months.
 

- Issue History
Date Modified Username Field Change
06-16-11 08:56 thr New Issue
06-16-11 08:56 thr File Added: test_array_ref.php
06-18-11 06:02 kdecherf Issue Monitored: kdecherf
01-30-12 11:35 krystian Note Added: 0005684
12-30-12 00:13 nam Note Added: 0006130
03-12-13 12:22 nam Status new => assigned
03-12-13 12:22 nam Assigned To  => nam
03-12-13 12:22 nam Status assigned => closed
03-12-13 12:22 nam Resolution open => unable to reproduce


Mantis 1.0.0rc3[^]
Copyright © 2000 - 2005 Mantis Group
35 total queries executed.
29 unique queries executed.
Powered by Mantis Bugtracker