Files
php-memcached/tests/experimental/setmulti_badserialize.phpt
Timo Tijhof 6d457155fb Remove "failed to set key" warning from setMulti (#490)
This was introduced in https://github.com/php-memcached-dev/php-memcached/commit/6837d89494,
pull https://github.com/php-memcached-dev/php-memcached/pull/214. I suspect it
may have been a left-over from debugging something. The test was later
changed in 6837d89494 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 #260, #409, #450, and more reports
within downstream issue trackers).

Closes https://github.com/php-memcached-dev/php-memcached/issues/409.
2021-08-22 21:56:19 -07:00

47 lines
938 B
PHP

--TEST--
Memcached::setMultiByKey() with bad serialize
--SKIPIF--
<?php include dirname(dirname(__FILE__)) . "/skipif.inc";?>
--FILE--
<?php
include dirname(dirname(__FILE__)) . '/config.inc';
$m = memc_get_instance ();
class Foo implements Serializable {
public function __sleep() {
throw new Exception("12");
}
public function __wakeup() {
throw new Exception("1234567890");
}
public function serialize() {
throw new Exception("1234");
}
public function unserialize($str) {
throw new Exception("123456");
}
}
error_reporting(0);
$m->setByKey('kef', 'foo', 10, 10);
try {
var_dump($m->setMultiByKey('kef', array('foo' => new Foo()), 10));
} catch (Exception $e) {
if (version_compare(phpversion(), "5.3.0", ">=")) {
if ($e->getPrevious()) {
$e = $e->getPrevious();
}
}
echo error_get_last()["message"], "\n";
echo $e->getMessage(), "\n";
}
var_dump($m->getByKey('kef', 'foo'));
--EXPECT--
1234
int(10)