Skip to content

Commit a8ed240

Browse files
authored
Merge pull request #247 from realmfoo/incrdecr_fix
Fix #243: Increment/decrement of an undefined key returns false with RES_SUCCESS
2 parents 0986493 + f31ad20 commit a8ed240

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

php_memcached.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2248,11 +2248,11 @@ static void php_memc_incdec_impl(INTERNAL_FUNCTION_PARAMETERS, zend_bool by_key,
22482248
}
22492249
}
22502250

2251-
if (value == UINT64_MAX) {
2251+
if (s_memc_status_handle_result_code(intern, status) == FAILURE) {
22522252
RETURN_FALSE;
22532253
}
22542254

2255-
if (s_memc_status_handle_result_code(intern, status) == FAILURE) {
2255+
if (value == UINT64_MAX) {
22562256
RETURN_FALSE;
22572257
}
22582258

tests/incrdecr.phpt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,11 @@ $m = memc_get_instance ();
1010
echo "Not there\n";
1111
$m->delete('foo');
1212
var_dump($m->increment('foo', 1));
13+
var_dump($m->getResultCode());
1314
var_dump($m->decrement('foo', 1));
15+
var_dump($m->getResultCode());
1416
var_dump($m->get('foo'));
17+
var_dump($m->getResultCode());
1518

1619
echo "Normal\n";
1720
$m->set('foo', 1);
@@ -37,8 +40,11 @@ var_dump($m->get('foo'));
3740
--EXPECT--
3841
Not there
3942
bool(false)
43+
int(16)
4044
bool(false)
45+
int(16)
4146
bool(false)
47+
int(16)
4248
Normal
4349
int(1)
4450
int(2)

0 commit comments

Comments
 (0)