|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #48658 Change in behaviour of parse_str on php 6.0
Submitted: 2009-06-23 09:51 UTC Modified: 2009-06-28 02:36 UTC
From: wharmby at uk dot ibm dot com Assigned: felipe (profile)
Status: Closed Package: Strings related
PHP Version: 6CVS-2009-06-23 (snap) OS: Windows XP
Private report: No CVE-ID: None
 [2009-06-23 09:51 UTC] wharmby at uk dot ibm dot com
Optional result argument of parse_str now has to be predefined as an
array.  In previous versions the 2nd optional argument of parse-str 
could either be an undefined variable or even an existing non-array 
variable. Either way the function returned the expected array populated with the parsed string. In PHP 6.0 the argument has to 
be a pre-defined array.  

Modifying the test below as follows:

$s1 = "first=val1&second=val2&third=val3";
$res1 = array();
parse_str($s1, $res1);


fixes the problem but this is not required on 5.2 and 5.3 so requirement will break applications when they are ported to PHP6. 

Is this an intended change in behavior or just a side affect 
introduced when parse_str modified to use zend_parse_parameters()?

Should code not be: 

	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|z", &enc_string, &enc_string_len, &result) == FAILURE) {

to maintain the 5./5.3 behaiviour ?

Reproduce code:
$s1 = "first=val1&second=val2&third=val3";
parse_str($s1, $res1);


Expected result:
array(3) {
  unicode(4) "val1"
  unicode(4) "val2"
  unicode(4) "val3"

Actual result:
Warning: parse_str() expects parameter 2 to be array, null given in ......


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2009-06-23 23:25 UTC] wharmby at uk dot ibm dot com
The following new PHP 6 tests dropped into cvs tagged as XFAIL due to this bug

 [2009-06-28 02:36 UTC]
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
Thank you for the report, and for helping us make PHP better.

PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Wed Dec 07 09:05:53 2022 UTC