This forum is in READ-ONLY mode.
You can look around, but if you want to ask a new question, please use the new forum.
Home » support » General discussion » Be aware of php 5.2!
Be aware of php 5.2! [message #15684] Fri, 10 November 2006 08:59 Go to next message
tuct  is currently offline tuct
Messages: 50
Registered: March 2006
Member
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

42 $this->test = array();
43 foreach ($array as $value){
44 array_push($this->test,$value);
45 }

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 Smile
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

Re: Be aware of php 5.2! [message #15686 is a reply to message #15684 ] Fri, 10 November 2006 10:05 Go to previous messageGo to next message
halfer  is currently offline halfer
Messages: 9535
Registered: January 2006
Location: West Midlands, UK
Faithful Member
Yep. Also:

http://www.symfony-project.com/forum/index.php/m/15652/#msg_ 15652

[Updated on: Fri, 10 November 2006 10:05]


Remember Palestine
Re: Be aware of php 5.2! [message #16662 is a reply to message #15684 ] Tue, 28 November 2006 05:12 Go to previous messageGo to next message
ooper  is currently offline 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 Smile
$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?

Re: Be aware of php 5.2! [message #16717 is a reply to message #15684 ] Tue, 28 November 2006 18:50 Go to previous messageGo to next message
tuct  is currently offline tuct
Messages: 50
Registered: March 2006
Member
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?
Re: Be aware of php 5.2! [message #20292 is a reply to message #16717 ] Wed, 24 January 2007 06:43 Go to previous messageGo to next message
spascoe  is currently offline 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

http://bugs.php.net/bug.php?id=40216

Scott
icon4.gif  Re: Be aware of php 5.2! [message #20312 is a reply to message #20292 ] Wed, 24 January 2007 11:43 Go to previous messageGo to next message
dante  is currently offline dante
Messages: 157
Registered: July 2006
Location: Germany
Senior Member

There has been an answer to your bug posting on php.net, your code does not seem to work. Maybe you should have a look at it.
Re: Be aware of php 5.2! [message #20341 is a reply to message #20312 ] Wed, 24 January 2007 15:33 Go to previous message
spascoe  is currently offline 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.

Scott
Previous Topic:schema xml, database name and propel
Next Topic:Shopping cart plugin losing content
Goto Forum:
  

powered by FUDforum - copyright ©2001-2004 FUD Forum Bulletin Board Software