php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #59227 Connect function does not return correct
Submitted: 2010-05-22 16:28 UTC Modified: 2010-06-01 11:06 UTC
From: info at theindustry dot se Assigned:
Status: Not a bug Package: memcache (PECL)
PHP Version: 5.3.0 OS: XP
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: info at theindustry dot se
New email:
PHP Version: OS:

 

 [2010-05-22 16:28 UTC] info at theindustry dot se
Description:
------------
Hi everyone,

If I try to connect to a memcached server that doesnt exist or is running, the connect is always True, but if I enter a host name that is obviously wrong, the return is False.
This appears very strange to me. Shouldn't the memcache return FALSE when a connection couldnt be made, as according to the PHP documentation?

Reproduce code:
---------------
1:

    $testInstance = new Memcache;
    $var = @$testInstance->connect('localhost', 11211);
    echo $var;
    // Outputs true no matter if the memcached is running or not.



2:

    $testInstance = new Memcache;
    $var = @$testInstance->connect('blablabla', 11211);
    echo $var;
    // Outputs false

Actual result:
--------------
Result of connections to non-existent servers returns true.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-06-01 11:06 UTC] hradtke@php.net
I cannot recreate this.  My memcached server runs on port 11212.

Code:
<?php
$testInstance = new Memcache;
$var = @$testInstance->connect('localhost', 11212);
var_dump($var);

$testInstance = new Memcache;
$var = @$testInstance->connect('localhost', 11211);
var_dump($var);

Output:
bool(true)
bool(false)
 
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Tue Oct 04 11:03:58 2022 UTC