Bug #54232 [NEW]: Crashes with magic method __set()
| From: | rantes dot javier at gmail dot com | Date: | Fri, 11 Mar 2011 21:07:53 +0000 |
| Subject: | Bug #54232 [NEW]: Crashes with magic method __set() | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-159408@lists.php.net to get a copy of this message | ||
From:
Operating system: winxp
PHP version: 5.2.17
Package: Compile Failure
Bug Type: Bug
Bug description:Crashes with magic method __set()
Description:
------------
I'm developing an OOP FrameWork and i'm improving ActiveRecord. My AR class
extends from ArrayObject Class from PHP and when i try to set an AR Object
into
another, mixing the _data array between normally vars and an AR, PHP
crushes and
server crash.
If i do this:
class ActiveRecord extends ArrayObject{
public function __set($name, $value) {
$this->_data[$name] = $value;
}
}
class A extends ActiveRecord{
public function __construct(){
}
}
class B extends ActiveRecord{
public function __construct(){
}
}
$A = new A;
$B = new B;
$A->foo = 3; // everything alright, no crushes.
$B->var = 4; // everything alright, no crushes.
$B->A = $A; // Crush!!!!
When i tried this, the server goes down, but i figured out to use another
array
for the AR objects apart from the $_data array and its works.
This works:
public function __set($name, $value) {
if(is_object($value) and
strcmp(get_parent_class($value),'ActiveRecord')===0):
$this->_models[$name] = $value;
else:
$this->_data[$name] = $value;
endif;
}
So, why does it happens??
--
Edit bug report at http://bugs.php.net/bug.php?id=54232&edit=1
--
Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=54232&r=trysnapshot52
Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=54232&r=trysnapshot53
Try a snapshot (trunk): http://bugs.php.net/fix.php?id=54232&r=trysnapshottrunk
Fixed in SVN: http://bugs.php.net/fix.php?id=54232&r=fixed
Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=54232&r=needdocs
Fixed in release: http://bugs.php.net/fix.php?id=54232&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=54232&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=54232&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=54232&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=54232&r=support
Expected behavior: http://bugs.php.net/fix.php?id=54232&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=54232&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=54232&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=54232&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=54232&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=54232&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=54232&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=54232&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=54232&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=54232&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=54232&r=mysqlcfg