| modification, are permitted provided that the conditions mentioned |
| in the accompanying LICENSE file are met. |
+--------------------------------------------------------------------+
- | Copyright (c) 2004-2006, Michael Wallner <mike@php.net> |
+ | Copyright (c) 2004-2007, Michael Wallner <mike@php.net> |
+--------------------------------------------------------------------+
*/
#include "php_http_querystring_api.h"
#ifdef ZEND_ENGINE_2
-#define OBJ_PROP_CE http_querystring_object_ce
+#define THIS_CE http_querystring_object_ce
extern zend_class_entry *http_querystring_object_ce;
#endif
return http_querystring_modify_array(qarray, params);
} else if (Z_TYPE_P(params) == IS_OBJECT) {
#ifdef ZEND_ENGINE_2
- if (!instanceof_function(Z_OBJCE_P(params), http_querystring_object_ce TSRMLS_CC)) {
+ if (instanceof_function(Z_OBJCE_P(params), http_querystring_object_ce TSRMLS_CC)) {
+ return http_querystring_modify_array(qarray, zend_read_property(THIS_CE, params, ZEND_STRS("queryArray")-1, 0 TSRMLS_CC));
+ } else {
#endif
- zval temp_array;
- INIT_ZARR(temp_array, HASH_OF(params));
- return http_querystring_modify_array(qarray, &temp_array);
+ return http_querystring_modify_array(qarray, params);
#ifdef ZEND_ENGINE_2
}
- return http_querystring_modify_array(qarray, GET_PROP_EX(params, queryArray));
#endif
} else {
int rv;
zval array;
+ zval *qstring = http_zsep(IS_STRING, params);
INIT_PZVAL(&array);
array_init(&array);
- ZVAL_ADDREF(params);
- convert_to_string_ex(¶ms);
- sapi_module.treat_data(PARSE_STRING, estrdup(Z_STRVAL_P(params)), &array TSRMLS_CC);
- zval_ptr_dtor(¶ms);
+ sapi_module.treat_data(PARSE_STRING, estrdup(Z_STRVAL_P(qstring)), &array TSRMLS_CC);
+ zval_ptr_dtor(&qstring);
+
rv = http_querystring_modify_array(qarray, &array);
zval_dtor(&array);
return rv;
HashPosition pos;
zval **params_entry = NULL;
- FOREACH_KEYVAL(pos, params, key, params_entry) {
+ FOREACH_HASH_KEYVAL(pos, HASH_OF(params), key, params_entry) {
/* only public properties */
if ((key.type != HASH_KEY_IS_STRING || *key.str) && http_querystring_modify_array_ex(qarray, key.type, key.str, key.len, key.num, *params_entry)) {
rv = 1;
}
/* add */
- ZVAL_ADDREF(params_entry);
if (Z_TYPE_P(params_entry) == IS_OBJECT) {
- convert_to_array_ex(¶ms_entry);
+ zval *new_array;
+
+ MAKE_STD_ZVAL(new_array);
+ array_init(new_array);
+ http_querystring_modify_array(new_array, params_entry);
+ params_entry = new_array;
+ } else {
+ ZVAL_ADDREF(params_entry);
}
if (key_type == HASH_KEY_IS_STRING) {
add_assoc_zval_ex(qarray, key, keylen, params_entry);