From a41703eafb1f1bb7f2968e97d471499c986a471b Mon Sep 17 00:00:00 2001 From: Michael Wallner Date: Sun, 18 Jan 2015 10:38:11 +0100 Subject: [PATCH] zend_hash_get_current_key_ex does not accept NULL for position anymore --- php_http_env.c | 2 +- php_http_env_response.c | 2 +- php_http_header.c | 2 +- php_http_misc.h | 3 +++ php_http_negotiate.h | 2 +- php_http_params.c | 19 ++++++++++--------- 6 files changed, 17 insertions(+), 13 deletions(-) diff --git a/php_http_env.c b/php_http_env.c index a2390b3..a2c3227 100644 --- a/php_http_env.c +++ b/php_http_env.c @@ -33,7 +33,7 @@ PHP_RINIT_FUNCTION(http_env) zend_string *key_str; zend_ulong key_num; - if (HASH_KEY_IS_STRING == zend_hash_get_current_key_ex(¶ms, &key_str, &key_num, NULL)) { + if (HASH_KEY_IS_STRING == zend_hash_get_current_key(¶ms, &key_str, &key_num)) { sapi_post_entry *post_entry = NULL; if ((post_entry = zend_hash_find_ptr(&SG(known_post_content_types), key_str))) { diff --git a/php_http_env_response.c b/php_http_env_response.c index f9e8c4c..34bc753 100644 --- a/php_http_env_response.c +++ b/php_http_env_response.c @@ -502,7 +502,7 @@ static ZEND_RESULT_CODE php_http_env_response_send_head(php_http_env_response_t zend_ulong index = 0; zend_hash_internal_pointer_reset(result); - if (HASH_KEY_IS_STRING == zend_hash_get_current_key_ex(result, &key_str, &index, NULL)) { + if (HASH_KEY_IS_STRING == zend_hash_get_current_key(result, &key_str, &index)) { if (zend_string_equals_literal(key_str, "gzip")) { if (!(r->content.encoder = php_http_encoding_stream_init(NULL, php_http_encoding_stream_get_deflate_ops(), PHP_HTTP_DEFLATE_TYPE_GZIP))) { ret = FAILURE; diff --git a/php_http_header.c b/php_http_header.c index 709b85b..0ae381e 100644 --- a/php_http_header.c +++ b/php_http_header.c @@ -187,7 +187,7 @@ PHP_METHOD(HttpHeader, unserialize) zend_ulong idx; zend_hash_internal_pointer_reset(&ht); - switch (zend_hash_get_current_key_ex(&ht, &key, &idx, NULL)) { + switch (zend_hash_get_current_key(&ht, &key, &idx)) { case HASH_KEY_IS_STRING: zend_update_property_str(php_http_header_class_entry, getThis(), ZEND_STRL("name"), key); break; diff --git a/php_http_misc.h b/php_http_misc.h index 204d0e3..32f2bc5 100644 --- a/php_http_misc.h +++ b/php_http_misc.h @@ -176,6 +176,9 @@ static inline ZEND_RESULT_CODE php_http_ini_entry(const char *name_str, size_t n return FAILURE; } +#define Z_ISUSER(zv) (Z_TYPE(zv) <= 10) +#define Z_ISUSER_P(zvp) Z_ISUSER(*(zvp)) + #define RETVAL_STR_COPY(zs) ZVAL_STR_COPY(return_value, zs) #define RETURN_STR_COPY(zs) do { \ ZVAL_STR_COPY(return_value, zs); \ diff --git a/php_http_negotiate.h b/php_http_negotiate.h index 598e871..58b7093 100644 --- a/php_http_negotiate.h +++ b/php_http_negotiate.h @@ -102,7 +102,7 @@ static inline HashTable *php_http_negotiate_content_type(HashTable *supported, p zend_string *key; \ zend_ulong idx; \ \ - if (zend_hash_num_elements(result) && HASH_KEY_IS_STRING == zend_hash_get_current_key_ex(result, &key, &idx, NULL)) { \ + if (zend_hash_num_elements(result) && HASH_KEY_IS_STRING == zend_hash_get_current_key(result, &key, &idx)) { \ RETVAL_STR_COPY(key); \ } else { \ PHP_HTTP_DO_NEGOTIATE_DEFAULT(supported); \ diff --git a/php_http_params.c b/php_http_params.c index ad32f0e..2f73cb9 100644 --- a/php_http_params.c +++ b/php_http_params.c @@ -397,7 +397,7 @@ static void merge_param(HashTable *params, zval *zdata, zval **current_param, zv } #endif - zend_hash_get_current_key_ex(Z_ARRVAL_P(zdata), &hkey.key, &hkey.h, NULL); + zend_hash_get_current_key(Z_ARRVAL_P(zdata), &hkey.key, &hkey.h); if ((hkey.key && !zend_hash_exists(params, hkey.key)) || (!hkey.key && !zend_hash_index_exists(params, hkey.h)) @@ -444,7 +444,7 @@ static void merge_param(HashTable *params, zval *zdata, zval **current_param, zv while (Z_TYPE_P(zdata_ptr) == IS_ARRAY && (test_ptr = zend_hash_get_current_data(Z_ARRVAL_P(zdata_ptr)))) { if (Z_TYPE_P(test_ptr) == IS_ARRAY) { /* now find key in ptr */ - if (HASH_KEY_IS_STRING == zend_hash_get_current_key_ex(Z_ARRVAL_P(zdata_ptr), &hkey.key, &hkey.h, NULL)) { + if (HASH_KEY_IS_STRING == zend_hash_get_current_key(Z_ARRVAL_P(zdata_ptr), &hkey.key, &hkey.h)) { if ((ptr = zend_hash_find(Z_ARRVAL_P(ptr), hkey.key))) { zdata_ptr = test_ptr; } else { @@ -472,7 +472,7 @@ static void merge_param(HashTable *params, zval *zdata, zval **current_param, zv zval_dtor(ptr); array_init(ptr); } - if (HASH_KEY_IS_STRING == zend_hash_get_current_key_ex(Z_ARRVAL_P(zdata_ptr), &hkey.key, &hkey.h, NULL)) { + if (HASH_KEY_IS_STRING == zend_hash_get_current_key(Z_ARRVAL_P(zdata_ptr), &hkey.key, &hkey.h)) { ptr = zend_hash_update(Z_ARRVAL_P(ptr), hkey.key, test_ptr); } else if (hkey.h) { ptr = zend_hash_index_update(Z_ARRVAL_P(ptr), hkey.h, test_ptr); @@ -543,10 +543,11 @@ static void push_param(HashTable *params, php_http_params_state_t *state, const ZVAL_NULL(&key); sanitize_key(opts->flags, state->param.str, state->param.len, &key, &rfc5987); state->rfc5987 = rfc5987; - if (Z_TYPE(key) != IS_STRING) { + if (Z_TYPE(key) == IS_ARRAY) { merge_param(params, &key, &state->current.val, &state->current.args); - } else if (Z_STRLEN(key)) { - array_init_size(&prm, 2); + } else if (Z_TYPE(key) == IS_STRING && Z_STRLEN(key)) { + //array_init_size(&prm, 2); + array_init(&prm); if (!Z_ISUNDEF(opts->defval)) { ZVAL_COPY_VALUE(&val, &opts->defval); @@ -559,8 +560,8 @@ static void push_param(HashTable *params, php_http_params_state_t *state, const } else { state->current.val = zend_hash_str_update(Z_ARRVAL(prm), "value", lenof("value"), &val); } - - array_init_size(&arg, 3); + //array_init_size(&arg, 3); + array_init(&arg); state->current.args = zend_hash_str_update(Z_ARRVAL(prm), "arguments", lenof("arguments"), &arg); state->current.param = zend_symtable_str_update(params, Z_STRVAL(key), Z_STRLEN(key), &prm); } @@ -712,7 +713,7 @@ static inline void shift_rfc5987(php_http_buffer_t *buf, zval *zvalue, const cha php_http_arrkey_t key = {0}; if ((zdata = zend_hash_get_current_data(ht)) - && HASH_KEY_NON_EXISTENT != zend_hash_get_current_key_ex(ht, &key.key, &key.h, NULL) + && HASH_KEY_NON_EXISTENT != zend_hash_get_current_key(ht, &key.key, &key.h) ) { php_http_arrkey_stringify(&key, NULL); php_http_buffer_appendf(buf, "*%.*sutf-8'%.*s'", -- 2.30.2