|  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
 [2008-05-12 00:09 UTC] orgchart at yahoo dot com
addServer() always returns true, regardless if a connection was made or not.

Reproduce code:

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);


Expected result:
object(Memcache)#1 (1) {
  resource(7) of type (memcache connection)

Actual result:
object(Memcache)#1 (1) {
  resource(7) of type (memcache connection)


Add a Patch

Pull Requests

Add a Pull Request


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 ( 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-2023 The PHP Group
All rights reserved.
Last updated: Sat Dec 02 01:01:27 2023 UTC