zval **params_entry = NULL;
FOREACH_KEYLENVAL(pos, params, key, keylen, idx, params_entry) {
- if (http_querystring_modify_array_ex(qarray, key ? HASH_KEY_IS_STRING : HASH_KEY_IS_LONG, key, keylen, idx, *params_entry)) {
+ /* only public properties */
+ if ((!key || *key) && http_querystring_modify_array_ex(qarray, key ? HASH_KEY_IS_STRING : HASH_KEY_IS_LONG, key, keylen, idx, *params_entry)) {
rv = 1;
}
key = NULL;
zval equal;
/* recursive */
- if (Z_TYPE_P(params_entry) == IS_ARRAY) {
- return http_querystring_modify_array(*qarray_entry, params_entry);
+ if (Z_TYPE_P(params_entry) == IS_ARRAY || Z_TYPE_P(params_entry) == IS_OBJECT) {
+ return http_querystring_modify(*qarray_entry, params_entry);
}
/* equal */
if ((SUCCESS == is_equal_function(&equal, *qarray_entry, params_entry TSRMLS_CC)) && Z_BVAL(equal)) {
/* add */
ZVAL_ADDREF(params_entry);
+ if (Z_TYPE_P(params_entry) == IS_OBJECT) {
+ convert_to_array_ex(¶ms_entry);
+ }
if (key_type == HASH_KEY_IS_STRING) {
add_assoc_zval_ex(qarray, key, keylen, params_entry);
} else {
qarr = GET_PROP_EX(zobj, queryArray);
qstr = GET_PROP_EX(zobj, queryString);
- array_copy(orig, qarr);
+ http_querystring_modify(qarr, orig);
http_querystring_modify(qarr, params);
http_querystring_update(qarr, qstr);
}
if (key) {
+ if (!*key) {
+ /* only public properties */
+ continue;
+ }
if (len && key[len - 1] == '\0') {
--len;
}
phpstr_fix(&new_prefix);
}
- if (Z_TYPE_PP(data) == IS_ARRAY) {
+ if (Z_TYPE_PP(data) == IS_ARRAY || Z_TYPE_PP(data) == IS_OBJECT) {
STATUS status;
++ht->nApplyCount;
- status = http_urlencode_hash_recursive(Z_ARRVAL_PP(data), str, arg_sep, arg_sep_len, PHPSTR_VAL(&new_prefix), PHPSTR_LEN(&new_prefix));
+ status = http_urlencode_hash_recursive(HASH_OF(*data), str, arg_sep, arg_sep_len, PHPSTR_VAL(&new_prefix), PHPSTR_LEN(&new_prefix));
--ht->nApplyCount;
if (SUCCESS != status) {
phpstr_dtor(&new_prefix);
<license>BSD, revised</license>
<notes><![CDATA[
* Fixed HttpResponse::capture() failure if buffered output exceeds 40k
+* Fixed HttpQueryString failures with objects as params
* Added HttpQueryString::mod(array $params) method
* Added ArrayAccess to interfaces implemented by HttpQueryString
* Added HttpMessage::getHeader(string $name) method
--SKIPIF--
<?php
include 'skip.inc';
-checkver(5);
+checkmin(5.1);
?>
--FILE--
<?php
--SKIPIF--
<?php
include 'skip.inc';
-checkver(5);
+checkmin(5);
?>
--FILE--
<?php
--- /dev/null
+--TEST--
+HttpQueryString w/ objects
+--SKIPIF--
+<?php
+include 'skip.inc';
+checkmin(5);
+?>
+--FILE--
+<?php
+echo "-TEST\n";
+$foo = (object) array("bar" => (object) array("baz" => 1), "\0*\0prop" => "dontshow");
+$foo->bar->baz = 1;
+var_dump($q = new HttpQueryString(false, $foo));
+$foo->bar->baz = 0;
+var_dump($q->mod($foo));
+echo "Done\n";
+?>
+--EXPECTF--
+%sTEST
+object(HttpQueryString)#3 (2) {
+ ["queryArray:private"]=>
+ array(1) {
+ ["bar"]=>
+ array(1) {
+ ["baz"]=>
+ int(1)
+ }
+ }
+ ["queryString:private"]=>
+ string(14) "bar%5Bbaz%5D=1"
+}
+object(HttpQueryString)#4 (2) {
+ ["queryArray:private"]=>
+ array(1) {
+ ["bar"]=>
+ array(1) {
+ ["baz"]=>
+ int(0)
+ }
+ }
+ ["queryString:private"]=>
+ string(14) "bar%5Bbaz%5D=0"
+}
+Done