Hi,
why has the support for http arrays (bracket syntax) been removed in PHP
5.1.3 ? Yes [] not allowed by according RFC, but is that a reason for
an BC break? Is it an accident or harassment?
patrick
Hi,
why has the support for http arrays (bracket syntax) been removed in PHP
5.1.3 ? Yes [] not allowed by according RFC, but is that a reason for
an BC break? Is it an accident or harassment?
What are you talking about?
--
Wbr,
Antony Dovgal
Antony Dovgal wrote:
Hi,
why has the support for http arrays (bracket syntax) been removed in
PHP 5.1.3 ? Yes [] not allowed by according RFC, but is that a
reason for an BC break? Is it an accident or harassment?What are you talking about?
probably a reference to the 'correct' but rather annoying BC break in http_build_query()
countless php apps make use of the ability of php to automatically convent get/post args
whose names are suffixed with square brackets into [sub]arrays in the relevant superglobal
array ... some of those app also make use of http_build_query()
to 'cleanly' create
url query parameter strings that e.g.
$args = array('foo' => array('bar' => array(1,2,3), 'quz' => array(1,2,3)));
echo '/foo.php?'.http_build_query($args);
foo.php --- 8< ---
var_dump($_GET['foo']);
the var_dump()
output used to be a neat nested array, but since 5.1.3 [although I remember
it as 5.1.6] http_build_query()
makes htmlentities of the square brackets so therefore
the var_dump()
gives you a string.
the workable 'fix' I have been using was to postprocess http_build_query()
output
with the following - a 'solution' which makes my skin crawl just a little:
function http_build_query_unborker($s)
{
return preg_replace('#%5bd#ei', 'urldecode("\0")', $s);
}
Jochem Maas wrote:
$args = array('foo' => array('bar' => array(1,2,3), 'quz' => array(1,2,3)));
echo '/foo.php?'.http_build_query($args);foo.php --- 8< ---
var_dump($_GET['foo']);
the
var_dump()
output used to be a neat nested array, but since 5.1.3 [although I remember
it as 5.1.6]http_build_query()
makes htmlentities of the square brackets so therefore
thevar_dump()
gives you a string.
Works as expected here with v5.2
Regards,
Michael
Michael Wallner wrote:
Jochem Maas wrote:
$args = array('foo' => array('bar' => array(1,2,3), 'quz' => array(1,2,3)));
echo '/foo.php?'.http_build_query($args);foo.php --- 8< ---
var_dump($_GET['foo']);
the
var_dump()
output used to be a neat nested array, but since 5.1.3 [although I remember
it as 5.1.6]http_build_query()
makes htmlentities of the square brackets so therefore
thevar_dump()
gives you a string.Works as expected here with v5.2
I'll take your word on it (although I can't be sure exactly what it is that you expected),
which means the change has been reverted, or the input parsing stuff has been changed to
recognize escaped square brackets as if they were not escaped - I know for sure
that http_build_query()
did escape quare brackets in 5.1.6 and that url query strings
that included escaped square brackets were not parsed into [nested] arrays.
a bug closed bug shows that this was changed for 5.1.3:
http://bugs.php.net/bug.php?id=36656
Regards,
Jochem Maas wrote:
I'll take your word on it (although I can't be sure exactly what it is that you expected),
which means the change has been reverted, or the input parsing stuff has been changed to
recognize escaped square brackets as if they were not escaped - I know for sure
thathttp_build_query()
did escape quare brackets in 5.1.6 and that url query strings
that included escaped square brackets were not parsed into [nested] arrays.
"expected" means that I get
array(1) {
["a"]=>
array(1) {
[0]=>
string(1) "1"
}
}
for get.php?a%5B%5D=1
--
Michael
Michael Wallner schrieb:
Jochem Maas wrote:
"expected" means that I get
array(1) {
["a"]=>
array(1) {
[0]=>
string(1) "1"
}
}for get.php?a%5B%5D=1
damn! a vanilla example works fine for me too.
looks this happens only under certain conditions.
i'll look at it again and report if i can reproduce it.
thanks.
sorry for the noise - having gone back and tested again I can
no longer reproduce my original problem (the OP seemingly had the
same issue).
whatever problem I was having, related to encoding of square brackets,
seems to have disappeared. sometimes I feel like I'm living in the twilight zone :-P
today there is no spoon.
Michael Wallner wrote:
Jochem Maas wrote:
I'll take your word on it (although I can't be sure exactly what it is that you expected),
which means the change has been reverted, or the input parsing stuff has been changed to
recognize escaped square brackets as if they were not escaped - I know for sure
thathttp_build_query()
did escape quare brackets in 5.1.6 and that url query strings
that included escaped square brackets were not parsed into [nested] arrays."expected" means that I get
array(1) {
["a"]=>
array(1) {
[0]=>
string(1) "1"
}
}for get.php?a%5B%5D=1
Jochem Maas wrote:
the
var_dump()
output used to be a neat nested array, but since 5.1.3 [although I remember
it as 5.1.6]http_build_query()
makes htmlentities of the square brackets so therefore
thevar_dump()
gives you a string.
It's in the changelog for 5.1.3:
- Fixed bug #36656 (http_build_query generates invalid URIs due to use
of square brackets). (Mike)
It works as expected for me in 5.1.6, using URL-encoding rather than
HTML-entities. (5.1.3 is badly broken anyway -- that's why 5.1.4 was
released so soon after.) So there's no bug that I can see.
--
Chad Daelhousen
I've been programming for about 15 years, but it's only in the last
couple that I've come to a real understanding of it all.