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
