diff options
author | Nicolas Favre-Felix <n.favrefelix@gmail.com> | 2012-09-10 03:29:44 +0400 |
---|---|---|
committer | Nicolas Favre-Felix <n.favrefelix@gmail.com> | 2012-09-10 03:29:44 +0400 |
commit | 6dc3ad6cb3bbadb5daabb53edbda093cf21a03d2 (patch) | |
tree | ff40640111792a6709a8a99ec806032f8ce81faa /redis_array.c | |
parent | 5855cfc2ca0e2dbe5fa754e3eeb092ef4d89a7eb (diff) |
Fix RedisArray::_rehash to support closures
* Add "f" parameter in _rehash()
* Call object with new method
* Add rehash test with closure
Diffstat (limited to 'redis_array.c')
-rw-r--r-- | redis_array.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/redis_array.c b/redis_array.c index 7964c818..380c53c1 100644 --- a/redis_array.c +++ b/redis_array.c @@ -499,11 +499,13 @@ PHP_METHOD(RedisArray, _distributor) PHP_METHOD(RedisArray, _rehash) { - zval *object, *z_cb = NULL; + zval *object; RedisArray *ra; + zend_fcall_info z_cb; + zend_fcall_info_cache z_cb_cache; - if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O|z", - &object, redis_array_ce, &z_cb) == FAILURE) { + if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O|f", + &object, redis_array_ce, &z_cb, &z_cb_cache) == FAILURE) { RETURN_FALSE; } @@ -511,7 +513,11 @@ PHP_METHOD(RedisArray, _rehash) RETURN_FALSE; } - ra_rehash(ra, z_cb TSRMLS_CC); + if (ZEND_NUM_ARGS() == 0) { + ra_rehash(ra, NULL, NULL TSRMLS_CC); + } else { + ra_rehash(ra, &z_cb, &z_cb_cache TSRMLS_CC); + } } static void multihost_distribute(INTERNAL_FUNCTION_PARAMETERS, const char *method_name) |