Bug #67182 [NEW]: asort() broken with boolean values.

From: Date: Fri, 02 May 2014 15:55:51 +0000
Subject: Bug #67182 [NEW]: asort() broken with boolean values.
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-185583@lists.php.net to get a copy of this message
From: php at liambowers dot co dot uk Operating system: Windows 7 PHP version: 5.4.28 Package: Arrays related Bug Type: Bug Bug description:asort() broken with boolean values. Description: ------------ When using asort() with a boolean true value in any other position than the first item in an array, it breaks. Tried with versions 5.4.28 (Win7), 5.4.27 (Win7), 5.4.12 (Win7) and 5.4.10 (OSX) Test script: --------------- $tests = array( 'test_with_boolean_broken_1' => array('a', true, 'b', 'c'), 'test_with_boolean_broken_2' => array('a', 'b', 'c', true), 'test_with_boolean_working_1' => array(true, 'a', 'b', 'c'), 'test_without_boolean_working' => array('a', 1, 'b', 'c') ); foreach($tests as $test_name => $test_data) { echo '<h1>' . $test_name . '</h1>'; echo '<li>data 1 (unsorted):<pre>' . print_r($test_data, true) . '</pre>'; asort($test_data); echo '<li>data 2 (sorted):<pre>' . print_r($test_data, true) . '</pre>'; asort($test_data); echo '<li>data 3 (resorted 1):<pre>' . print_r($test_data, true) . '</pre>'; asort($test_data); echo '<li>data 4 (resorted 2):<pre>' . print_r($test_data, true) . '</pre>'; } Expected result: ---------------- When using: Array ( [0] => a [1] => 1 [2] => b [3] => c ) Result should be: Array ( [0] => a [2] => b [3] => c [1] => 1 ) Actual result: -------------- After asort() #1: Array ( [2] => b [3] => c [1] => 1 [0] => a ) After asort() #2: Array ( [0] => a [2] => b [3] => c [1] => 1 ) After asort() #3: Array ( [0] => a [1] => 1 [2] => b [3] => c ) -- Edit bug report at https://bugs.php.net/bug.php?id=67182&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=67182&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=67182&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=67182&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=67182&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=67182&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=67182&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=67182&r=needscript Try newer version: https://bugs.php.net/fix.php?id=67182&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=67182&r=support Expected behavior: https://bugs.php.net/fix.php?id=67182&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=67182&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=67182&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=67182&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=67182&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=67182&r=dst IIS Stability: https://bugs.php.net/fix.php?id=67182&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=67182&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=67182&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=67182&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=67182&r=mysqlcfg

« previous php.bugs (#185583) next »