php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #56477 connect() changes the class when extending from the memcache class
Submitted: 2005-08-05 07:22 UTC Modified: 2005-08-05 07:43 UTC
From: martijn at brothersinart dot net Assigned:
Status: Closed Package: memcache (PECL)
PHP Version: 5.0.3 OS: Red Hat Enterprise Linux ES rele
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: martijn at brothersinart dot net
New email:
PHP Version: OS:

 

 [2005-08-05 07:22 UTC] martijn at brothersinart dot net
Description:
------------
I have a memcache (version 1.4) setup working on my PHP 5.0.4 config. 

When I try to subclass the memcache class I get some unexpected results when I call the connect() function. It connects allright, but changes the type of the class, and "forgets" the variables the class allready had. 

I allready took a peek in the memcache.c sourcefile, and I think the problem is on line 1418 or 1419, but I have no idea how to fix the problem. Is there anybody who van help me?

PHP configure line: './configure' '--prefix=/usr/local/lib/php5' '--with-mysql=/usr/local/mysql/' '--with-apxs2=/usr/local/apache2-php5/bin/apxs' '--with-gd=/usr/local/'

Lines added in php.ini: 
extension=memcache.so

Reproduce code:
---------------
<?
$memcache = new MemcacheConnection( "localhost" );
var_dump($memcache);
$memcache->connect();
var_dump($memcache);

class MemcacheConnection extends Memcache 
{
	private $host, $port, $persistent;
	
	function __construct( $host, $port = 11211, $persistent = false ) {
		$this->host = $host;
		$this->port = $port;
		$this->persistent = $persistent;
	}

	function connect() {
		if( !parent::connect( $this->host, $this->port ) )
			throw new Exception( "Could not connect to memcache on ".$this->host );
	}
}
?>

Expected result:
----------------
object(MemcacheConnection)#1 (3) {
  ["host:private"]=>
  string(9) "localhost"
  ["port:private"]=>
  int(11211)
  ["persistent:private"]=>
  bool(false)
}
object(MemcacheConnection)#1 (3) {
  ["host:private"]=>
  string(9) "localhost"
  ["port:private"]=>
  int(11211)
  ["persistent:private"]=>
  bool(false)
  ["connection"]=>
  resource(4) of type (memcache connection)
}


Actual result:
--------------
object(MemcacheConnection)#1 (3) {
  ["host:private"]=>
  string(9) "localhost"
  ["port:private"]=>
  int(11211)
  ["persistent:private"]=>
  bool(false)
}
object(Memcache)#1 (1) {
  ["connection"]=>
  resource(4) of type (memcache connection)
}

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-08-05 07:43 UTC] tony2001 at phpclub dot net
Fixed in release 1.5 (released few seconds ago).
This release also includes minor memory leak fix.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Dec 27 19:01:28 2024 UTC