From: weierophinney
Operating system: Linux 32-bit
PHP version: 5.3.5
Package: SPL related
Bug Type: Bug
Bug description:Data registered with equal priority not returned in expected
order
Description:
------------
SplPriorityQueue does not behave as expected when data is registered with
equal
priority. One would expect one of the following situations:
* The data retain the same order as how they were registered
* The data are ordered based on value
Neither of these are the case, however. From empirical analysis, it appears
that
the following happens:
* The first item registered at that priority will always be the first
returned
* The remaining items are returned in the reverse order in which they were
enqueued.
Test script:
---------------
$queue = new SplPriorityQueue();
$queue->insert('foo', 100);
$queue->insert('bar', 100);
$queue->insert('baz', 100);
$queue->insert('bat', 100);
foreach ($queue as $data) {
echo $data, "\n";
}
Expected result:
----------------
// IDEALLY order in which they are registered:
foo
bar
baz
bat
// OR following same rules as priority queue -- higher values == higher
priority
foo
baz
bat
bar
Actual result:
--------------
foo
bat
baz
bar
--
Edit bug report at http://bugs.php.net/bug.php?id=53710&edit=1
--
Try a snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=53710&r=trysnapshot52
Try a snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=53710&r=trysnapshot53
Try a snapshot (trunk):
http://bugs.php.net/fix.php?id=53710&r=trysnapshottrunk
Fixed in SVN:
http://bugs.php.net/fix.php?id=53710&r=fixed
Fixed in SVN and need be documented:
http://bugs.php.net/fix.php?id=53710&r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=53710&r=alreadyfixed
Need backtrace:
http://bugs.php.net/fix.php?id=53710&r=needtrace
Need Reproduce Script:
http://bugs.php.net/fix.php?id=53710&r=needscript
Try newer version:
http://bugs.php.net/fix.php?id=53710&r=oldversion
Not developer issue:
http://bugs.php.net/fix.php?id=53710&r=support
Expected behavior:
http://bugs.php.net/fix.php?id=53710&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=53710&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=53710&r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=53710&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=53710&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=53710&r=dst
IIS Stability:
http://bugs.php.net/fix.php?id=53710&r=isapi
Install GNU Sed:
http://bugs.php.net/fix.php?id=53710&r=gnused
Floating point limitations:
http://bugs.php.net/fix.php?id=53710&r=float
No Zend Extensions:
http://bugs.php.net/fix.php?id=53710&r=nozend
MySQL Configuration Error:
http://bugs.php.net/fix.php?id=53710&r=mysqlcfg