From: bugs dot php dot net at chsc dot dk Operating system: Linux PHP version: 4.3.7 PHP Bug Type: Arrays related Bug description: usort() does not trigger an error when callback does not exist
Description: ------------ When the second argument to usort() is not a valid callback, no error is triggered, and the return value is true. This makes debugging tricky. When invoked with an invalid callback, usort() for some reason rearranges the values in the array anyway. Reproduce code: --------------- <?php error_reporting(E_ALL); $array = array(1, 7, 3, 2); var_dump(usort($array, 'not a function name')); var_dump($array); var_dump(usort($array, 9999)); var_dump($array); var_dump(usort($array, array('foo', 'bar'))); var_dump($array); ?> Expected result: ---------------- The output should be three error messages, three times "bool(false)" and three times the original array. Actual result: -------------- bool(true) array(4) { [0]=> int(2) [1]=> int(3) [2]=> int(7) [3]=> int(1) } bool(true) array(4) { [0]=> int(1) [1]=> int(7) [2]=> int(3) [3]=> int(2) } bool(true) array(4) { [0]=> int(2) [1]=> int(3) [2]=> int(7) [3]=> int(1) } -- Edit bug report at http://bugs.php.net/?id=29049&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=29049&r=trysnapshot4 Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=29049&r=trysnapshot5 Fixed in CVS: http://bugs.php.net/fix.php?id=29049&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=29049&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=29049&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=29049&r=needscript Try newer version: http://bugs.php.net/fix.php?id=29049&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=29049&r=support Expected behavior: http://bugs.php.net/fix.php?id=29049&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=29049&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=29049&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=29049&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=29049&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=29049&r=dst IIS Stability: http://bugs.php.net/fix.php?id=29049&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=29049&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=29049&r=float