From: nikic
Operating system:
PHP version: 5.5.0RC3
Package: Scripting Engine problem
Bug Type: Bug
Bug description:count() off by one inside unset()
Description:
------------
If code is run inside an array offset unset the reported size of that array
will be off by one:
<?php
class Foo {
public $array;
public function __destruct() {
var_dump(count($this->array[0]));
var_dump($this->array[0]);
}
}
$array = [[new Foo]];
$array[0][0]->array =& $array;
unset($array[0][0]);
Outputs:
int(1)
array(1) {
}
The reason is that zend_hash_del_key_or_index decrements the element count
*after* calling the bucket dtor.
--
Edit bug report at https://bugs.php.net/bug.php?id=65051&edit=1
--
Try a snapshot (PHP 5.4):
https://bugs.php.net/fix.php?id=65051&r=trysnapshot54
Try a snapshot (PHP 5.3):
https://bugs.php.net/fix.php?id=65051&r=trysnapshot53
Try a snapshot (trunk):
https://bugs.php.net/fix.php?id=65051&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=65051&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=65051&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=65051&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=65051&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=65051&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=65051&r=support
Expected behavior: https://bugs.php.net/fix.php?id=65051&r=notwrong
Not enough info:
https://bugs.php.net/fix.php?id=65051&r=notenoughinfo
Submitted twice:
https://bugs.php.net/fix.php?id=65051&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=65051&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=65051&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=65051&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=65051&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=65051&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=65051&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=65051&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=65051&r=mysqlcfg