From: wharmby at uk dot ibm dot com Operating system: Windows XP PHP version: 6CVS-2009-06-23 (snap) PHP Bug Type: Strings related Bug description: Change in behaviour of parse_str on php 6.0
Description: ------------ 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: <?php $s1 = "first=val1&second=val2&third=val3"; $res1 = array(); parse_str($s1, $res1); var_dump($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) { return; } to maintain the 5./5.3 behaiviour ? Reproduce code: --------------- <?php $s1 = "first=val1&second=val2&third=val3"; parse_str($s1, $res1); var_dump($res1); ?> Expected result: ---------------- array(3) { [u"first"]=> unicode(4) "val1" [u"second"]=> unicode(4) "val2" [u"third"]=> unicode(4) "val3" } Actual result: -------------- NULL Warning: parse_str() expects parameter 2 to be array, null given in ...... -- Edit bug report at http://bugs.php.net/?id=48658&edit=1 -- Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=48658&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=48658&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=48658&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=48658&r=fixedcvs Fixed in CVS and need be documented: http://bugs.php.net/fix.php?id=48658&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=48658&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=48658&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=48658&r=needscript Try newer version: http://bugs.php.net/fix.php?id=48658&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=48658&r=support Expected behavior: http://bugs.php.net/fix.php?id=48658&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=48658&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=48658&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=48658&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=48658&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=48658&r=dst IIS Stability: http://bugs.php.net/fix.php?id=48658&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=48658&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=48658&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=48658&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=48658&r=mysqlcfg