#50688 [NEW]: Warning When Handling Exception in a usort Callback Function
From: jcampbell at remindermedia dot com
Operating system: Fedora Core 12
PHP version: 5.3.1
PHP Bug Type: Arrays related
Bug description: Warning When Handling Exception in a usort Callback Function
Description:
------------
If the callback function used by usort handles an exception using a
try/catch block, a warning is generated. The correct sorting is still done.
This happens even when the exception & handling doesn't involve the
variables.
The example below is the usort example from the manual with only the
try/catch block added. Reproducible in PHP 5.2.11 but not 5.2.9
Reproduce code:
---------------
<?php
function cmp($a, $b)
{
if ($a == $b) {
return 0;
}
try {
throw new Exception();
} catch (Exception $E) {
}
return ($a < $b) ? -1 : 1;
}
$a = array(3, 2, 5, 6, 1);
usort($a, "cmp");
Expected result:
----------------
No warning message.
Actual result:
--------------
PHP Warning: usort(): Array was modified by the user comparison function
in /home/jcampbell/usortExceptionWarning.php on line 19
--
Edit bug report at http://bugs.php.net/?id=50688&edit=1
--
Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=50688&r=trysnapshot52
Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=50688&r=trysnapshot53
Try a snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=50688&r=trysnapshot60
Fixed in SVN: http://bugs.php.net/fix.php?id=50688&r=fixed
Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=50688&r=needdocs
Fixed in release: http://bugs.php.net/fix.php?id=50688&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=50688&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=50688&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=50688&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=50688&r=support
Expected behavior: http://bugs.php.net/fix.php?id=50688&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=50688&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=50688&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=50688&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=50688&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=50688&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=50688&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=50688&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=50688&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=50688&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=50688&r=mysqlcfg
Thread (20 messages)
- jcampbell at remindermedia dot com
- jani@php.net#50688 [Opn->Ver]: Warning When Handling Exception in a usort Callback Function
- federico dot lebron at gmail dot com#50688 [Com]: Warning When Handling Exception in a usort Callback Function
- jani@php.net#50688 [Ver->Asn]: Using exceptions inside usort() callback function causes a warning
- "Bug #50688 [Com]: Using exceptions inside usort() callback function causes a warning
- stas@php.netBug #50688 [Com]: Using exceptions inside usort() callback function causes a warning
- ajrattink at correct dot netBug #50688 [Com]: Using exceptions inside usort() callback function causes a warning
- philipwhiuk at hotmail dot comBug #50688 [Com]: Using exceptions inside usort() callback function causes a warning
- poehler at interworx dot comBug #50688 [Com]: Using exceptions inside usort() callback function causes a warning
- eric_haney at yahoo dot comBug #50688 [Com]: Using exceptions inside usort() callback function causes a warning
- keith at breadvault dot comBug #50688 [Com]: Using exceptions inside usort() callback function causes a warning
- mbrowne83 at gmail dot comBug #50688 [Com]: Using exceptions inside usort() callback function causes a warning
- andrejs dot verza at gmail dot comBug #50688 [Com]: Using exceptions inside usort() callback function causes a warning
- jakub dot lopuszanski at nasza-klasa dot plBug #50688 [Com]: Using exceptions inside usort() callback function causes a warning
- m at rtin dot soBug #50688 [Com]: Using exceptions inside usort() callback function causes a warning
- m at rtin dot soBug #50688 [Com]: Using exceptions inside usort() callback function causes a warning
- nikic@php.netBug #50688 [Asn]: Using exceptions inside usort() callback function causes a warning
- albert at mediatribe dot netBug #50688 [Com]: Using exceptions inside usort() callback function causes a warning
- love at sickpeople dot seBug #50688 [Com]: Using exceptions inside usort() callback function causes a warning
- nikic@php.netBug #50688 [Asn->Csd]: Using exceptions inside usort() callback function causes a warning