php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #58193 addServer always returns true
Submitted: 2008-05-12 00:09 UTC Modified: 2008-05-12 03:29 UTC
From: orgchart at yahoo dot com Assigned:
Status: Not a bug Package: memcache (PECL)
PHP Version: 5.1.6 OS: CentOS
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.
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: orgchart at yahoo dot com
New email:
PHP Version: OS:

 

 [2008-05-12 00:09 UTC] orgchart at yahoo dot com
Description:
------------
addServer() always returns true, regardless if a connection was made or not.

Reproduce code:
---------------
<?php

system('memcached -d -p 11211 -u nobody -c 64 -m 64 -P /var/run/memcached/11211');
system('memcached -d -p 11212 -u nobody -c 64 -m 64 -P /var/run/memcached/11211');
$memcache = new Memcache;
$res = $memcache->addServer('localhost', 11211);
var_dump ($res);
$res = $memcache->addServer('localhost', 11212);
var_dump ($res);
$res = $memcache->addServer('localhost', 11213);
var_dump ($res);

var_dump($memcache);
?>

Expected result:
----------------
bool(true)
bool(true)
bool(false)
object(Memcache)#1 (1) {
  ["connection"]=>
  resource(7) of type (memcache connection)
}

Actual result:
--------------
bool(true)
bool(true)
bool(true)
object(Memcache)#1 (1) {
  ["connection"]=>
  resource(7) of type (memcache connection)
}

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-05-12 03:29 UTC] mikael at synd dot info
Thank you for taking the time to write to us, but this is not
a bug.

As indicated in the API docs (http://www.php.net/manual/en/function.Memcache-addServer.php) the connection isn't established until actually needed. 

If you really want all connections to be established and tested (note that there's some overhead in this, thus the lazy connect policy of addServer) you should use the connect/pconnect methods instead.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 13:01:31 2024 UTC