From:
Operating system: Debian Linux 6.0.4
PHP version: 5.3.13
Package: SPL related
Bug Type: Bug
Bug description:different ways of iterating over an SplMaxHeap result in
different keys
Description:
------------
If I use a foreach-loop to iterate over an SplMaxHeap,
the first key is 1. If I use the "key" method, the
first key is 0.
Just in case it's relevant, this is the "configure"
command I used to compile PHP. (Don't be misled by
the value for "prefix"; I'm using PHP 5.3.13, not
PHP 5.3.12.)
./configure --prefix=/usr/local/php/5.3.12 --disable-cgi --with-
pgsql=shared,/usr --with-xmlrpc=shared --with-tidy=shared,/usr --with-
mssql=shared,/usr --with-sqlite=shared,/usr --with-snmp=shared,/usr
--with-
xsl=shared,/usr --with-recode=shared,/usr --with-unixODBC=shared,/usr
--with-
pspell=shared,/usr --with-mysqli=shared,/usr/bin/mysql_config --with-
mysql=shared,/usr --with-mcrypt=shared,/usr --with-ldap-sasl=/usr --with-
ldap=shared,/usr --with-t1lib=shared,/usr --with-ttf=shared,/usr --enable-
intl=shared --with-pdo-firebird=shared,/usr --with-interbase=shared,/usr
--with-
imap-ssl --with-freetype-dir=shared,/usr --with-png-dir=shared,/usr
--with-xpm-
dir=shared,/usr/X11R6 --with-jpeg-dir=shared,/usr --with-gmp=shared,/usr
--
enable-gd-native-ttf --with-gd=shared,/usr --with-zlib-dir=/usr --with-
enchant=shared,/usr --with-curl=shared,/usr --without-mm --with-mhash=yes
--
enable-zip --enable-soap --with-openssl=/usr --with-kerberos=/usr
--with-zlib --
with-libxml-dir=/usr --enable-wddx --enable-sockets --enable-shmop
--with-pcre-
regex=/usr --with-onig=/usr --enable-mbstring --with-gettext --enable-ftp
--
enable-exif --with-iconv --without-gdbm --with-db4 --enable-ctype
--with-bz2 --
enable-bcmath --enable-sysvmsg --enable-sysvshm --enable-sysvsem --enable-
calendar --with-pic --disable-static --disable-rpath --with-regex=php
--disable-
debug --enable-pcntl --with-readline
Test script:
---------------
<?php
$heap = new SplMaxHeap;
$heap->insert(42);
foreach ($heap as $key => $value) {
break;
}
var_dump($key);
var_dump($value);
$heap = new SplMaxHeap;
$heap->insert(42);
var_dump($heap->key());
var_dump($heap->current());
Expected result:
----------------
I expect to see 4 lines of output from the script,
and, among other things, I expect the third line to be
the same as the first line.
Actual result:
--------------
The script gives this output:
int(1)
int(42)
int(0)
int(42)
Note that the third line differs from
the first.
--
Edit bug report at https://bugs.php.net/bug.php?id=62073&edit=1
--
Try a snapshot (PHP 5.4):
https://bugs.php.net/fix.php?id=62073&r=trysnapshot54
Try a snapshot (PHP 5.3):
https://bugs.php.net/fix.php?id=62073&r=trysnapshot53
Try a snapshot (trunk):
https://bugs.php.net/fix.php?id=62073&r=trysnapshottrunk
Fixed in SVN:
https://bugs.php.net/fix.php?id=62073&r=fixed
Fixed in SVN and need be documented:
https://bugs.php.net/fix.php?id=62073&r=needdocs
Fixed in release:
https://bugs.php.net/fix.php?id=62073&r=alreadyfixed
Need backtrace:
https://bugs.php.net/fix.php?id=62073&r=needtrace
Need Reproduce Script:
https://bugs.php.net/fix.php?id=62073&r=needscript
Try newer version:
https://bugs.php.net/fix.php?id=62073&r=oldversion
Not developer issue:
https://bugs.php.net/fix.php?id=62073&r=support
Expected behavior:
https://bugs.php.net/fix.php?id=62073&r=notwrong
Not enough info:
https://bugs.php.net/fix.php?id=62073&r=notenoughinfo
Submitted twice:
https://bugs.php.net/fix.php?id=62073&r=submittedtwice
register_globals:
https://bugs.php.net/fix.php?id=62073&r=globals
PHP 4 support discontinued:
https://bugs.php.net/fix.php?id=62073&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=62073&r=dst
IIS Stability:
https://bugs.php.net/fix.php?id=62073&r=isapi
Install GNU Sed:
https://bugs.php.net/fix.php?id=62073&r=gnused
Floating point limitations:
https://bugs.php.net/fix.php?id=62073&r=float
No Zend Extensions:
https://bugs.php.net/fix.php?id=62073&r=nozend
MySQL Configuration Error:
https://bugs.php.net/fix.php?id=62073&r=mysqlcfg