Just updated my testserver to php 5.2
first small issue:
if u are in an action or component and iterate over an array with foreach don't try to set the value of an overloaded class variable (array) in the foreach loop
will lead to this error:
Notice: Indirect modification of overloaded property rezepteComponents::$test has no effect in /**/apps/frontend/modules/test/actions/components.class.php on line 44
will work
42 $test = array();
43 foreach ($array as $value){
44 array_push($test,$value);
45 }
46 $this->test = $test;
as far as i know the __get() function only returns avariable in read mode while foreach expects it in read/write mode
maybe that helps someone take me some time to figure out
ooper Messages: 9 Registered: December 2005 Location: Toronto, Canada
Junior Member
Since moving to php 5.2. I had this problem and your tip was extremely helpful in fixing it ...
//in the execute() code for an action...
//this doesn't work, as $x is undefined in the related Success template
$this->x = array();
foreach ( $this->getSomething() as $id => $datarecord ){
...
$this->x[$id] = $someresult;
}
//but this works
$x = array();
foreach ( $this->getSomething() as $id => $datarecord ){
...
$x[$id] = $someresult;
}
$this->x = $x;
//-------------------------------
I can't understand what is happening and that is a bit unsettling. Does anyone have an explanation?
as i wrote above:
the __get() function only return the variable in read mode but foreach expects it in read/write mode
in your code:
$this->x = array(); => overloaded property
foreach ( $this->getSomething() as $id => $datarecord ){
...
$this->x[$id] = $someresult; // $this->x uses the __get function but now only returns the value in read mode (dif to php5.1x) here is the error
} http://bugs.php.net/bug.php?id=39449
php bug?
spascoe Messages: 52 Registered: November 2005 Location: Indianapolis
Member
The php but #39449 was supposed to be fixed on 2007-01-07, but wasn't completely resolved. I created a test to repoduce the error's that are being seen by the symfony framework and file it as php bug
spascoe Messages: 52 Registered: November 2005 Location: Indianapolis
Member
I've submitted a ticket http://www.symfony-project.com/trac/ticket/1376 with a patch to correct sfComponent::__get for future versions of PHP, but PHP 5.2.0 does not work correctly on this.