X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-http;a=blobdiff_plain;f=php_http_querystring.c;h=d2657484668ade531a876860c51354707e06a99e;hp=7304d6915f31420608bc2d15543ed8166ef0463e;hb=4a975fc65c1885c505cb1271411cef14724caf4c;hpb=8b8cdb96032f50d57dbdad74ae45336d01a7f0c5 diff --git a/php_http_querystring.c b/php_http_querystring.c index 7304d69..d265748 100644 --- a/php_http_querystring.c +++ b/php_http_querystring.c @@ -6,7 +6,7 @@ | modification, are permitted provided that the conditions mentioned | | in the accompanying LICENSE file are met. | +--------------------------------------------------------------------+ - | Copyright (c) 2004-2013, Michael Wallner | + | Copyright (c) 2004-2014, Michael Wallner | +--------------------------------------------------------------------+ */ @@ -76,7 +76,7 @@ static inline void php_http_querystring_get(zval *this_ptr, int type, char *name } #ifdef PHP_HTTP_HAVE_ICONV -STATUS php_http_querystring_xlate(zval *dst, zval *src, const char *ie, const char *oe TSRMLS_DC) +ZEND_RESULT_CODE php_http_querystring_xlate(zval *dst, zval *src, const char *ie, const char *oe TSRMLS_DC) { HashPosition pos; zval **entry = NULL; @@ -131,7 +131,7 @@ STATUS php_http_querystring_xlate(zval *dst, zval *src, const char *ie, const ch } #endif /* HAVE_ICONV */ -STATUS php_http_querystring_ctor(zval *instance, zval *params TSRMLS_DC) +ZEND_RESULT_CODE php_http_querystring_ctor(zval *instance, zval *params TSRMLS_DC) { php_http_querystring_set(instance, params, 0 TSRMLS_CC); return SUCCESS; @@ -158,9 +158,9 @@ static int apply_querystring(void *pData TSRMLS_DC) return ZEND_HASH_APPLY_KEEP; } -STATUS php_http_querystring_parse(HashTable *ht, const char *str, size_t len TSRMLS_DC) +ZEND_RESULT_CODE php_http_querystring_parse(HashTable *ht, const char *str, size_t len TSRMLS_DC) { - STATUS rv = FAILURE; + ZEND_RESULT_CODE rv = FAILURE; php_http_params_opts_t opts; php_http_params_token_t psep = { ZEND_STRL("&") }, *psepp[] = { &psep, NULL }; php_http_params_token_t vsep = { ZEND_STRL("=") }, *vsepp[] = { &vsep, NULL }; @@ -206,7 +206,7 @@ STATUS php_http_querystring_parse(HashTable *ht, const char *str, size_t len TSR return rv; } -STATUS php_http_querystring_update(zval *qarray, zval *params, zval *outstring TSRMLS_DC) +ZEND_RESULT_CODE php_http_querystring_update(zval *qarray, zval *params, zval *outstring TSRMLS_DC) { /* enforce proper type */ if (Z_TYPE_P(qarray) != IS_ARRAY) { @@ -606,11 +606,19 @@ PHP_METHOD(HttpQueryString, offsetSet) return; } - MAKE_STD_ZVAL(param); - array_init(param); - Z_ADDREF_P(value); - add_assoc_zval_ex(param, offset_str, offset_len + 1, value); - php_http_querystring_set(getThis(), param, 0 TSRMLS_CC); + param = zend_read_property(php_http_querystring_class_entry, getThis(), ZEND_STRL("queryArray"), 0 TSRMLS_CC); + + if (Z_TYPE_P(param) == IS_ARRAY && zend_symtable_exists(Z_ARRVAL_P(param), offset_str, offset_len + 1)) { + Z_ADDREF_P(value); + zend_symtable_update(Z_ARRVAL_P(param), offset_str, offset_len + 1, (void *) &value, sizeof(zval *), NULL); + Z_ADDREF_P(param); + } else { + MAKE_STD_ZVAL(param); + array_init(param); + Z_ADDREF_P(value); + add_assoc_zval_ex(param, offset_str, offset_len + 1, value); + } + php_http_querystring_set(getThis(), param, QS_MERGE TSRMLS_CC); zval_ptr_dtor(¶m); }