Mantis Bugtracker
  

Viewing Issue Advanced Details Jump to Notes ] View Simple ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0003141 [Quercus] major always 12-10-08 01:57 01-09-09 21:10
Reporter mattsecrett View Status public  
Assigned To nam
Priority normal Resolution fixed Platform
Status closed   OS
Projection none   OS Version
ETA none Fixed in Version 4.0.0 Product Version 3.2.1
  Product Build
Summary 0003141: __get() not firing on $object->objects["name"]->value
Description
Hi,

Not sure if this is me doing something wrong, but if I have an object that has an array of objects, and I try to access a member variable of one of the child objects, using the format $object->objects["name"]->value, it returns nothing. If, however, I use $object->objects["name"]->__get("value"), it correctly returns the value. See test code below for example.

Thanks,

Matt

-------------------------------

class Test
{
    private $_values;

    public function __construct()
    {
        $this->_values = array();
    }

    public function __get($field)
    {
        return $this->_values[$field];
    }

    public function __set($field, $value)
    {
        $this->_values[$field] = $value;
        return true;
    }

    public function display($value)
    {
        echo "Here it is: $value
";
    }
}

function testResin()
{
    $test1 = new Test();

    $test1->fields = array();
    $test1->fields["field1"] = new Test();
    $test1->fields["field1"]->value = "I am field 1";

    $test2 = new Test();
    $test2->display($test1->fields["field1"]->value); // this fails
    $test2->display($test1->fields["field1"]->__get("value")); //this works
}
Steps To Reproduce
Additional Information
Attached Files  quercus_ArgGetValue.zip [^] (3,427 bytes) 01-09-09 07:59

- Relationships

- Notes
(0003710)
haplo
01-09-09 08:06

The problem is that the function arguments are not resolved correctly.

If you use a method chain like $this->MagicGetOne->MagicGetTwo as a function argument quercus tries to get the Field MagicGetTwo from the $this->MagicGetOne but it does not execute the $this->MagicGetOne statement correctly.

I attached a fix. Just put the zip files into com.caucho.quercus.env package.

BTW:
Change the line
    $test2->display($test1->fields["field1"]->value);
to
    $test2->display($result = $test1->fields["field1"]->value);
this should work
 
(0003717)
nam
01-09-09 21:10

php/09kr
php/39kr
 

- Issue History
Date Modified Username Field Change
12-10-08 01:57 mattsecrett New Issue
01-09-09 07:59 haplo File Added: quercus_ArgGetValue.zip
01-09-09 08:06 haplo Note Added: 0003710
01-09-09 16:48 nam Status new => assigned
01-09-09 16:48 nam Assigned To  => nam
01-09-09 21:10 nam Status assigned => closed
01-09-09 21:10 nam Note Added: 0003717
01-09-09 21:10 nam Resolution open => fixed
01-09-09 21:10 nam Fixed in Version  => 4.0.0


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