php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #32626 dynamic object reference is not stored in a static var
Submitted: 2005-04-07 18:13 UTC Modified: 2005-04-07 22:25 UTC
From: jon dot brightwell at s2o dot co dot uk Assigned:
Status: Closed Package: Class/Object related
PHP Version: 5.0.4 OS: W2k srv IIS
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: jon dot brightwell at s2o dot co dot uk
New email:
PHP Version: OS:

 

 [2005-04-07 18:13 UTC] jon dot brightwell at s2o dot co dot uk
Description:
------------
$mcp is a class instance.
constructor of mcp stores a reference of itself in a seperate static class.

Reproduce code:
---------------
$yo = new mcp();

class mcp
{
	public function __construct()
	{
	    io_tower::setMCP($this);
        }
}

class io_tower
{

	static public function getMCP()
	{
		return self::$mcp;		
	}
	static public function setMCP($import)
	{
		try
		{
			if(is_object(self::$mcp)) throw new Exception("MCP already exists");
		}catch (Exception $e){return;}
		
		self::$mcp= $import;		
	}
}

Expected result:
----------------
io_tower(self)::$mcp = instance of mcp
ie. io_tower::getMCP() = instance

Actual result:
--------------
io_tower(self)::$mcp = null
ie. io_tower::getMCP() = null

Patches

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-04-07 18:14 UTC] sniper@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5-win32-latest.zip


 [2005-04-07 18:29 UTC] jon dot brightwell at s2o dot co dot uk
latest snapshot (5.1.0-dev) does work but breaks zends debugger;

Failed loading C:\Program Files\Zend\ZendStudioClient-4.0.0\lib\php5\ZendDebuggerLocal.dll

is there a snapshot that is still zend 4 compatible with the fix in?
 [2005-04-07 21:55 UTC] phpbugs at majiclab dot com
From what I see, you haven't declared a static class variable in io_tower.
 [2005-04-07 22:25 UTC] sniper@php.net
For the Zend stuff, ask someone working for Zend..
Otherwise -> closed.

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Sep 10 21:01:28 2024 UTC