mirror of
https://github.com/php-win-ext/php-memcached.git
synced 2026-03-24 00:52:18 +01:00
Fix more tests with a slight refactor
This commit is contained in:
committed by
Michael Wallner
parent
198e9b3681
commit
da71ae0362
@@ -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; \
|
||||
|
||||
@@ -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');
|
||||
|
||||
|
||||
@@ -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'));
|
||||
|
||||
Reference in New Issue
Block a user