|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2009-11-10 17:58 UTC] harv at pringo dot com
Description:
------------
CLIENT_ERROR bad command line format. Usage: delete <key> [noreply]
With the latest version of memcache 1.4.3, the delete syntax that the extension is sending is invalid. Extension is sending a 2nd parameter to memcache, and is failing to delete.
Simple fix:
memcache.c line 1494
// removes the 3rd param
command_len = spprintf(&command, 0, "delete %s", key);
Reproduce code:
---------------
$c = new Memcache();
$c->connect("127.0.0.1", 11211);
var_Dump($c->set("cache_key", "testing delete"));
var_Dump($c->delete("cache_key"));
Expected result:
----------------
bool(true)
bool(true)
Actual result:
--------------
bool(true)
bool(false)
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 08:00:02 2025 UTC |
Yesterday I tested memcached 1.4.4 and was not able to delete anything. Turns out that pecl/memcache 3.0.4 defaults to timeout 1 for deletes instead of 0. strace of PHP-process deleting a key without specifing timeout: sendto(3, "delete user:1354381 1\r\n", 23, MSG_NOSIGNAL, NULL, 0) = 23 Specifing the timeout to 0 sends an proper command: sendto(3, "delete user:1354381\r\n", 21, MSG_NOSIGNAL, NULL, 0) = 21 Turns out memcache.c uses "value" instead of "exptime" when running deletes and "value" is defaulted to 1(probably to be used with increment/decrement). Code: ----- long value = 1, defval = 0, exptime = 0; .... if (deleted) { if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|l", &keys, &value) == FAILURE) { Proposed fix: ------------- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|l", &keys, &exptime) == FAILURE) {The proposed fix from andrer is not complete, the delete functions deeper down in the function have to be changed from value to exptime: memcache.c: static void php_mmc_numeric(INTERNAL_FUNCTION_PARAMETERS, int deleted, int invert) /* if (mmc_object == NULL) { if (deleted) { if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Oz|l", &mmc_object, memcache_pool_ce, &keys, &exptime) == FAILURE) { return; } } else { if (deleted) { if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|l", &keys, &exptime) == FAILURE) { return; } } } if (Z_TYPE_P(keys) == IS_ARRAY) { while (zend_hash_get_current_data_ex(Z_ARRVAL_P(keys), (void **)&key, &pos) == SUCCESS) { zend_hash_move_forward_ex(Z_ARRVAL_P(keys), &pos); if (deleted) { pool->protocol->delete(request, request->key, request->key_len, exptime); } } } else { if (deleted) { pool->protocol->delete(request, request->key, request->key_len, exptime); } } NOTE: This is not the full function, just the parts that got value changed into exptime!Why is this marked as WONTFIX, when this is still a problem? This code fails: $memcache = new Memcache; $memcache->connect("tcp://localhost:11211/"); $memcache->delete("blabla"); ....with the same CLIENT_ERROR: [Thu Jun 03 00:28:30 2010] [error] [client 192.168.1.22] PHP Notice: MemcachePool::delete(): Server tcp://localhost:11211/ (tcp 11211, udp 0) failed with: CLIENT_ERROR bad command line format. Usage: delete <key> [noreply]\r\n (0) in [.....] How can this be considered anything but a regression? This code used to work, now it doesn't. All required arguments are present. (pecl memcache 3.04 and memcached 1.4.5)