Skip to content

Commit da71ae0

Browse files
rlerdorfm6w6
authored andcommitted
Fix more tests with a slight refactor
1 parent 198e9b3 commit da71ae0

File tree

3 files changed

+6
-7
lines changed

3 files changed

+6
-7
lines changed

php_memcached.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -246,10 +246,9 @@ zend_bool s_memc_valid_key_ascii(zend_string *key)
246246
#define MEMC_CHECK_KEY(intern, key) \
247247
if (UNEXPECTED(ZSTR_LEN(key) == 0 || \
248248
ZSTR_LEN(key) > MEMC_OBJECT_KEY_MAX_LENGTH || \
249-
memcached_behavior_get(intern->memc, MEMCACHED_BEHAVIOR_VERIFY_KEY) && \
250249
(memcached_behavior_get(intern->memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL) \
251250
? !s_memc_valid_key_binary(key) \
252-
: !s_memc_valid_key_ascii(key) \
251+
: (memcached_behavior_get(intern->memc, MEMCACHED_BEHAVIOR_VERIFY_KEY) && !s_memc_valid_key_ascii(key)) \
253252
))) { \
254253
intern->rescode = MEMCACHED_BAD_KEY_PROVIDED; \
255254
RETURN_FALSE; \

tests/get.phpt

+4-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ Memcached::get()
55
--FILE--
66
<?php
77
include dirname(__FILE__) . '/config.inc';
8-
$m = memc_get_instance ();
8+
$m = memc_get_instance (array (
9+
Memcached::OPT_BINARY_PROTOCOL => false,
10+
Memcached::OPT_VERIFY_KEY => true
11+
));
912

1013
$m->delete('foo');
1114

tests/keys_ascii.phpt

+1-4
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,8 @@ Test valid and invalid keys - ascii
88
include dirname (__FILE__) . '/config.inc';
99
$ascii = memc_get_instance (array (
1010
Memcached::OPT_BINARY_PROTOCOL => false,
11-
Memcached::OPT_VERIFY_KEY => false
11+
Memcached::OPT_VERIFY_KEY => true
1212
));
13-
// libmemcached can verify keys, but these are tests are for our own
14-
// function s_memc_valid_key_ascii, so explicitly disable the checks
15-
// that libmemcached can perform.
1613

1714
echo 'ASCII: SPACES' . PHP_EOL;
1815
var_dump ($ascii->set ('ascii key with spaces', 'this is a test'));

0 commit comments

Comments
 (0)