Edit report at http://bugs.php.net/bug.php?id=54232&edit=1

 ID:                 54232
 Updated by:         fel...@php.net
 Reported by:        rantes dot javier at gmail dot com
 Summary:            Crashes with magic method __set()
-Status:             Open
+Status:             Feedback
 Type:               Bug
 Package:            Compile Failure
 Operating System:   winxp
 PHP Version:        5.2.17
 Block user comment: N
 Private report:     N

 New Comment:

Thank you for this bug report. To properly diagnose the problem, we
need a backtrace to see what is happening behind the scenes. To
find out how to generate a backtrace, please read
http://bugs.php.net/bugs-generating-backtrace.php for *NIX and
http://bugs.php.net/bugs-generating-backtrace-win32.php for Win32

Once you have generated a backtrace, please submit it to this bug
report and change the status back to "Open". Thank you for helping
us make PHP better.




Previous Comments:
------------------------------------------------------------------------
[2011-03-11 22:07:53] rantes dot javier at gmail dot com

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 this bug report at http://bugs.php.net/bug.php?id=54232&edit=1

Reply via email to