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
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
47 + 44 = ?
Subscribe to this entry?

 
 [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

Pull Requests

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-2024 The PHP Group
All rights reserved.
Last updated: Tue Oct 08 12:01:26 2024 UTC