Skip to content

Commit 2af8314

Browse files
committed
moar tests passing
1 parent fe3090e commit 2af8314

File tree

4 files changed

+21
-18
lines changed

4 files changed

+21
-18
lines changed

php_memcached.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ typedef struct {
170170
} php_memc_t;
171171

172172
static inline php_memc_t *php_memc_fetch_object(zend_object *obj) {
173-
return (php_memc_t *)((char *)(obj) - XtOffsetOf(php_memc_t, zo));
173+
return (php_memc_t *)((char *)obj - XtOffsetOf(php_memc_t, zo));
174174
}
175175
#define Z_MEMC_OBJ_P(zv) php_memc_fetch_object(Z_OBJ_P(zv));
176176

@@ -356,20 +356,17 @@ char *php_memc_printable_func (zend_fcall_info *fci, zend_fcall_info_cache *fci_
356356
static zend_bool php_memcached_on_new_callback(zval *object, zend_fcall_info *fci, zend_fcall_info_cache *fci_cache, zend_string *persistent_id)
357357
{
358358
zend_bool ret = 1;
359-
zval retval;
360-
zval params[2];
359+
zval retval, id;
361360

362361
if (persistent_id) {
363-
ZVAL_STR(&params[1], persistent_id);
362+
ZVAL_STR(&id, persistent_id);
364363
} else {
365-
ZVAL_NULL(&params[1]);
364+
ZVAL_NULL(&id);
366365
}
367366

368-
/* Call the cb */
369-
ZVAL_COPY(&params[0], object);
367+
ZVAL_UNDEF(&retval);
370368

371-
fci->params = params;
372-
fci->param_count = 2;
369+
zend_fcall_info_argn(fci, 2, object, &id);
373370
fci->retval = &retval;
374371
fci->no_separation = 1;
375372

@@ -379,10 +376,12 @@ static zend_bool php_memcached_on_new_callback(zval *object, zend_fcall_info *fc
379376
efree (buf);
380377
ret = 0;
381378
}
379+
380+
if (Z_TYPE(retval) != IS_UNDEF)
381+
zval_ptr_dtor(&retval);
382+
383+
zend_fcall_info_args_clear(fci, 1);
382384

383-
zval_ptr_dtor(&params[0]);
384-
zval_ptr_dtor(&params[1]);
385-
zval_ptr_dtor(&retval);
386385
return ret;
387386
}
388387

@@ -408,7 +407,6 @@ static PHP_METHOD(Memcached, __construct)
408407
zend_fcall_info_cache fci_cache;
409408

410409
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|S!f!S", &persistent_id, &fci, &fci_cache, &conn_str) == FAILURE) {
411-
ZEND_CTOR_MAKE_NULL();
412410
return;
413411
}
414412

@@ -3304,6 +3302,7 @@ zend_bool s_unserialize_value (enum memcached_serializer serializer, int val_typ
33043302

33053303
PHP_VAR_UNSERIALIZE_INIT(var_hash);
33063304
if (!php_var_unserialize(value, (const unsigned char **)&payload_tmp, (const unsigned char *)payload_tmp + payload_len, &var_hash)) {
3305+
zval_ptr_dtor(value);
33073306
ZVAL_FALSE(value);
33083307
PHP_VAR_UNSERIALIZE_DESTROY(var_hash);
33093308
php_error_docref(NULL, E_WARNING, "could not unserialize value");
@@ -3538,6 +3537,7 @@ static memcached_return php_memc_do_cache_callback(zval *zmemc_obj, zend_fcall_i
35383537
fci->param_count = 4;
35393538

35403539
result = zend_call_function(fci, fcc);
3540+
35413541
ZVAL_DUP(value, Z_REFVAL(z_val));
35423542
expiration = Z_REFVAL(z_expiration);
35433543
if (result == SUCCESS && Z_TYPE(retval) != IS_UNDEF) {

tests/clone.phpt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,7 @@ $m = clone $m;
1212

1313
echo "GOT HERE";
1414
--EXPECTF--
15-
Fatal error: Trying to clone an uncloneable object of class Memcached in %s on line %d
15+
Fatal error: Uncaught Error: Trying to clone an uncloneable object of class Memcached in %s:6
16+
Stack trace:
17+
#0 {main}
18+
thrown in %s on line 6

tests/experimental/cas_invalid_key.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ error_reporting(0);
1111
var_dump($m->cas(0, '', true, 10));
1212
echo $m->getResultMessage(), "\n";
1313

14-
var_dump($m->cas(0, ' äö jas kjjhask d ', true, 10));
14+
var_dump($m->cas(0, ' äö jas kjjhask d ', true, 10)); # no spaces allowed
1515
echo $m->getResultMessage(), "\n";
1616

1717
--EXPECTF--
1818
bool(false)
1919
A BAD KEY WAS PROVIDED/CHARACTERS OUT OF RANGE
2020
bool(false)
21-
%rCLIENT ERROR|NOT FOUND%r
21+
A BAD KEY WAS PROVIDED/CHARACTERS OUT OF RANGE

tests/experimental/delete_bykey.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ var_dump($m->deleteByKey('keffe', ''));
2121
echo $m->getResultMessage(), "\n";
2222
var_dump($m->deleteByKey('', 'keffe'));
2323
echo $m->getResultMessage(), "\n";
24-
var_dump($m->deleteByKey('keffe', 'äöåasäö åaösdäf asdf'));
24+
var_dump($m->deleteByKey('keffe', 'äöåasäö åaösdäf asdf')); # no spaces allowed
2525
echo $m->getResultMessage(), "\n";
2626
--EXPECTF--
2727
string(3) "foo"
@@ -37,4 +37,4 @@ A BAD KEY WAS PROVIDED/CHARACTERS OUT OF RANGE
3737
bool(false)
3838
NOT FOUND
3939
bool(false)
40-
%rPROTOCOL ERROR|NOT FOUND|WRITE FAILURE|CLIENT ERROR%r
40+
A BAD KEY WAS PROVIDED/CHARACTERS OUT OF RANGE

0 commit comments

Comments
 (0)