php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #54232 Crashes with magic method __set()
Submitted: 2011-03-11 22:07 UTC Modified: 2013-02-18 00:34 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: rantes dot javier at gmail dot com Assigned:
Status: No Feedback Package: Scripting Engine problem
PHP Version: 5.2.17 OS: winxp
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: rantes dot javier at gmail dot com
New email:
PHP Version: OS:

 

 [2011-03-11 22:07 UTC] 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??


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-03-11 22:10 UTC] felipe@php.net
-Status: Open +Status: Feedback
 [2011-03-11 22:10 UTC] felipe@php.net
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.


 [2011-03-11 22:12 UTC] felipe@php.net
Btw, try using PHP 5.3.6RC3 or svn version.
 [2011-03-11 22:19 UTC] rantes dot javier at gmail dot com
-Status: Feedback +Status: Open
 [2011-03-11 22:19 UTC] rantes dot javier at gmail dot com
I can not use P.H.P. > 5.2.9 beecause the server is not mine and its a paid 
server. I have to fix to this requirement.
 [2011-03-11 23:34 UTC] felipe@php.net
-Status: Open +Status: Feedback -Package: Compile Failure +Package: Scripting Engine problem
 [2011-03-11 23:34 UTC] felipe@php.net
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.

I can't reproduce it.
 [2013-02-18 00:34 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Dec 06 02:01:29 2024 UTC