Bug #71067 [NEW]: Local object in class method stays in memory for each call
From: gal at webrats dot co dot il
Operating system: Centos 6.7
PHP version: 7.0.0
Package: *General Issues
Bug Type: Bug
Bug description:Local object in class method stays in memory for each call
Description:
------------
Local object variable inside a class method is not recreated in each
function call when executed from cli.
Works properly through php-fpm but outputs a different result when
executed through cli.
It does not happen without the (object) casting. Also if I'll
instantiate $arr with new stdClass() it will not happen.
Seems like the $arr = (object) is being preserved in the memory by
php7's engine.
Test script:
---------------
<?php
class Test {
public function test(){
$arr = (object) [
'children' => []
];
$arr->children[] = 1;
return $arr;
}
}
$o = new Test();
$o->test();
print_r( $o->test() );
Expected result:
----------------
stdClass Object
(
[children] => Array
(
[0] => 1
)
)
Actual result:
--------------
stdClass Object
(
[children] => Array
(
[0] => 1
[1] => 1
)
)
--
Edit bug report at https://bugs.php.net/bug.php?id=71067&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=71067&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=71067&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=71067&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=71067&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=71067&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=71067&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=71067&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=71067&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=71067&r=support
Expected behavior: https://bugs.php.net/fix.php?id=71067&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=71067&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=71067&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=71067&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=71067&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=71067&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=71067&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=71067&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=71067&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=71067&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=71067&r=mysqlcfg
Thread (7 messages)
- gal at webrats dot co dot il