Skip to content

Commit 97ee9f6

Browse files
committed
Remove "failed to set key" warning from setMulti
This was introduced in 6837d89494, pull php-memcached-dev#214. I suspect it may have been a left-over from debugging something. The test was later changed in 6837d89 to expect the warning in question, although other similar tests don't encounter such warning currently. It appears no other Memcached methods emit a PHP Warning when they encounter a write read or failure. Instead, they typically turn their return value into boolean false, and provide details via getResultMessage(). The introduction of this warning since php-memcached 3.0 has led to a number of confused consumers (locally php-memcached-dev#260, php-memcached-dev#409, php-memcached-dev#450, and more reports within downstream issue trackers). Closes php-memcached-dev#409.
1 parent 605a8a6 commit 97ee9f6

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

php_memcached.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1907,9 +1907,8 @@ static void php_memc_setMulti_impl(INTERNAL_FUNCTION_PARAMETERS, zend_bool by_ke
19071907
str_key = zend_string_init(tmp_key, tmp_len, 0);
19081908
}
19091909

1910-
if (!s_memc_write_zval (intern, MEMC_OP_SET, server_key, str_key, value, expiration)) {
1911-
php_error_docref(NULL, E_WARNING, "failed to set key %s", ZSTR_VAL(str_key));
1912-
}
1910+
/* If this failed to set a key, intern stores the error for the return value */
1911+
s_memc_write_zval (intern, MEMC_OP_SET, server_key, str_key, value, expiration)
19131912

19141913
if (!skey) {
19151914
zend_string_release (str_key);

tests/experimental/setmulti_badserialize.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ try {
3838

3939
echo error_get_last()["message"], "\n";
4040
echo $e->getMessage(), "\n";
41+
echo $m->getResultMessage(), "\n";
4142
}
4243
var_dump($m->getByKey('kef', 'foo'));
4344

4445
--EXPECT--
45-
Memcached::setMultiByKey(): failed to set key foo
4646
1234
4747
int(10)

0 commit comments

Comments
 (0)