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
View Add Comment Developer Edit
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:
35 + 16 = ?
Subscribe to this entry?

 
 [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

Add a Patch

Pull Requests

Add a Pull Request

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-2024 The PHP Group
All rights reserved.
Last updated: Wed May 01 23:01:28 2024 UTC