php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #59477 addServer()/addServers() never return FALSE
Submitted: 2010-10-26 14:30 UTC Modified: 2010-10-26 15:10 UTC
From: basilio dot vera at softonic dot com Assigned:
Status: Not a bug Package: memcached (PECL)
PHP Version: 5.2.10 OS: CentOS 5.5
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: basilio dot vera at softonic dot com
New email:
PHP Version: OS:

 

 [2010-10-26 14:30 UTC] basilio dot vera at softonic dot com
Description:
------------
When I try to force an error into the addServer()/addServers() I never get a false of the method call, and the result code is not right neither.

I tried to force an error to add some logic into my bussiness class, but I cannot find how to do it.

The doc says:

Returns TRUE on success or FALSE on failure. 

And:

The hostname of the memcache server. If the hostname is invalid, data-related operations will set Memcached::RES_HOST_LOOKUP_FAILURE result code. 

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

var_dump( Memcached::RES_HOST_LOOKUP_FAILURE );

$test = new Memcached();
var_dump( $test->addServers( array( array( 'error-1', 0 ), array( 'bad-host', 11211 ) ) ) );
var_dump( $test->getResultCode() );

var_dump( $test->addServer( 'bad-host-2', 11211 ) );
var_dump( $test->getResultCode() );

?>

Expected result:
----------------
int(2)
bool(false)
int(2)
bool(false)
int(2)

Actual result:
--------------
int(2)
bool(true)
int(0)
bool(true)
int(0)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-10-26 14:37 UTC] basilio dot vera at softonic dot com
Sorry, I've seen that this is cheched after the first real request to the server.

If I add these lines to the test code:

var_dump( $test->get( 'test1' ) );
var_dump( $test->getResultCode() );

I finally get the expected result:

bool(false)
int(2)

But I cannot know what exactly happened there, and what is the problematic server.
 [2010-10-26 15:09 UTC] andrei@php.net
addServer() is mapped to libmemcached's function directly, and 
is not designed to check whether the server name is valid or 
not. I suggest you do this validation in your code before the 
call to addServers().
 [2010-10-26 15:10 UTC] basilio dot vera at softonic dot com
On any case, there a mistake in the docs. That's why I was so surprised.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 11:01:27 2024 UTC