php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #58415 When set() fails no reason is given
Submitted: 2008-11-17 10:34 UTC Modified: 2008-11-17 12:06 UTC
From: dan at moo dot com Assigned:
Status: Not a bug Package: memcache (PECL)
PHP Version: 5.2.0 OS: n/a
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: dan at moo dot com
New email:
PHP Version: OS:

 

 [2008-11-17 10:34 UTC] dan at moo dot com
Description:
------------
Occasionally the set() method fails, but no reason is given as to why. Memcached returns the error (e.g. SERVER_ERROR out of memory) but this wrapper throws that error away instead of allowing the caller to find out why the set() failed (short of stracing, which can be a little to IO intensive on a large site with a seemingly randomly reoccurring set() problem)

Reproduce code:
---------------
if (!$memcache->set('key', 'value', MEMCACHE_COMPRESSED)) {
  print 'I failed to do your bidding but cannot for the life of me tell you why';
}
// You get the idea...

Expected result:
----------------
A helpful message that lets me know why I couldn't set a key/value pair

Actual result:
--------------
Nothing but a false.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-11-17 12:06 UTC] mikael at synd dot info
The error message is printed as an E_NOTICE if you don't have an failure callback set, if a failure callback is set the message is sent as the 4:th param to that callback.

If you don't see this message it might be because you have the error reporting level set to low, you can fix this by calling error_reporting(E_ALL) or modifying the matching php.ini setting.

Or using Memcache::addServer with a failure callback like

function my_failure_callback($host, $tcp_port, $udp_port, $error, $errnum) {
    print $error;
}

$memcache = new Memcache;
$memcache->addServer('localhost', 11211, true, 1, 1, 15, true, 'my_failure_callback');
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Jan 15 09:01:28 2025 UTC