php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #61736 warning in usort when calling debug_backtrace
Submitted: 2012-04-15 12:27 UTC Modified: 2013-01-31 14:42 UTC
Votes:7
Avg. Score:3.7 ± 1.4
Reproduced:6 of 6 (100.0%)
Same Version:2 (33.3%)
Same OS:4 (66.7%)
From: hosiplan at gmail dot com Assigned:
Status: Not a bug Package: Arrays related
PHP Version: 5.4.1 OS: Linux
Private report: No CVE-ID: None
 [2012-04-15 12:27 UTC] hosiplan at gmail dot com
Description:
------------
When I call a function debug_backtrace() in usort() callback, it triggers 
unrelated warning. 

When i var_dump() it's result, it's OK.


Verified on my mashine
$ php -v
PHP 5.3.11-dev (cli) (built: Mar  1 2012 16:31:39) 

and on my friend's mashine with 5.3.5

Test script:
---------------
<?php

error_reporting(E_ALL | E_STRICT);

$versions = array('1', '2');

usort($versions, function ($me, $him) {
	debug_backtrace(FALSE);
	return 1;
});


Expected result:
----------------
No warning

Actual result:
--------------
Warning: usort() [function.usort]: Array was modified by the user comparison 
function in /home/hosiplan/develop/testing/php/backtrace.error.php on line 18

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-04-16 08:17 UTC] hosiplan at gmail dot com
Affects version
 [2012-04-16 08:17 UTC] hosiplan at gmail dot com
-PHP Version: 5.3.10 +PHP Version: 5.4.1
 [2012-04-26 13:44 UTC] arjen at react dot com
This worked in 5.3.0, it's broken in 5.3.1-5.3.11 and 5.4.0-5.4.1.

http://3v4l.org/1UiAq
 [2013-01-31 14:17 UTC] christopher dot loerken at bytro dot com
This problem still exists in currentl stable 5.4.11
 [2013-01-31 14:42 UTC] johannes@php.net
-Status: Open +Status: Not a bug
 [2013-01-31 14:42 UTC] johannes@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

User debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); else the array is provided as a part of the retuned array. The engine then can'T guarantee there won't be any changes ... and changes during a sort can lead to unpredictable results.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 20 04:01:28 2024 UTC