Fix more tests with a slight refactor

This commit is contained in:
Rasmus Lerdorf
2023-10-19 21:42:43 -07:00
committed by Michael Wallner
parent 198e9b3681
commit da71ae0362
3 changed files with 6 additions and 7 deletions

View File

@@ -246,10 +246,9 @@ zend_bool s_memc_valid_key_ascii(zend_string *key)
#define MEMC_CHECK_KEY(intern, key) \
if (UNEXPECTED(ZSTR_LEN(key) == 0 || \
ZSTR_LEN(key) > MEMC_OBJECT_KEY_MAX_LENGTH || \
memcached_behavior_get(intern->memc, MEMCACHED_BEHAVIOR_VERIFY_KEY) && \
(memcached_behavior_get(intern->memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL) \
? !s_memc_valid_key_binary(key) \
: !s_memc_valid_key_ascii(key) \
: (memcached_behavior_get(intern->memc, MEMCACHED_BEHAVIOR_VERIFY_KEY) && !s_memc_valid_key_ascii(key)) \
))) { \
intern->rescode = MEMCACHED_BAD_KEY_PROVIDED; \
RETURN_FALSE; \

View File

@@ -5,7 +5,10 @@ Memcached::get()
--FILE--
<?php
include dirname(__FILE__) . '/config.inc';
$m = memc_get_instance ();
$m = memc_get_instance (array (
Memcached::OPT_BINARY_PROTOCOL => false,
Memcached::OPT_VERIFY_KEY => true
));
$m->delete('foo');

View File

@@ -8,11 +8,8 @@ Test valid and invalid keys - ascii
include dirname (__FILE__) . '/config.inc';
$ascii = memc_get_instance (array (
Memcached::OPT_BINARY_PROTOCOL => false,
Memcached::OPT_VERIFY_KEY => false
Memcached::OPT_VERIFY_KEY => true
));
// libmemcached can verify keys, but these are tests are for our own
// function s_memc_valid_key_ascii, so explicitly disable the checks
// that libmemcached can perform.
echo 'ASCII: SPACES' . PHP_EOL;
var_dump ($ascii->set ('ascii key with spaces', 'this is a test'));