From: ricardo dot saracino at seivu dot ca
Operating system: Linux
PHP version: 5.2.5
PHP Bug Type: Scripting Engine problem
Bug description: mem leak
Description:
------------
Last element or $data refers to the first $prod from the Product loop,
memory reference problem just thought Id make you aware of it because I
have been staring at my code for 30 min.
Reproduce code:
---------------
foreach( $data as &$group )
{
foreach( $group as $prodId=>&$prod )
{
if( !isset( $prod['Usage'] ) )
$prod['Usage'] = 0;
if( !isset( $prod['Owned'] ) )
$prod['Owned'] = 0;
$prod['Diff'] = $prod['Usage'] -
$prod['Owned'];
$heading[$prodId] = '';
}
}
foreach( Product::FindByCd( "Product",
array_keys($heading) ) as $prod
)
$heading[$prod->ProductID] = $prod->ProductName;
Expected result:
----------------
[148] => Array
(
[Owned] => 6
[Usage] => 4
[Diff] => -2
)
[102] => Array
(
[Owned] => 5
[Usage] => 3
[Diff] => -2
)
[126] => Array
(
[Usage] => 1
[Owned] => 0
[Diff] => 1
)
)
Actual result:
--------------
[148] => Array
(
[Owned] => 6
[Usage] => 4
[Diff] => -2
)
[102] => Array
(
[Owned] => 5
[Usage] => 3
[Diff] => -2
)
[126] => Product Object
(
[ProductID] => 148
[CallTypeID] => 1
[ProductSaleTypeID] =>
[ProductName] => 9242
[ProductDscrpn] => DUAL TUNER HD PVR
[BEVArticleNo] => 64300
[R00ReqdIndcr] => 1
[ProductValue] => 0.00
[ProductActiveIndcr] => 1
[DDPriority] => 1
[SubArticleNo] =>
[CurrentInventoryIndcr] => 1
[TunerNo] => 2
[HDIndcr] => 0
[DishIncludedIndcr] => 0
[Duration] =>
[RuleName] => 9200
[InstallerVuPriority] =>
)
)
--
Edit bug report at http://bugs.php.net/?id=43599&edit=1
--
Try a CVS snapshot (PHP 4.4):
http://bugs.php.net/fix.php?id=43599&r=trysnapshot44
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=43599&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=43599&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=43599&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=43599&r=fixedcvs
Fixed in release:
http://bugs.php.net/fix.php?id=43599&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=43599&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=43599&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=43599&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=43599&r=support
Expected behavior: http://bugs.php.net/fix.php?id=43599&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=43599&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=43599&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=43599&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=43599&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=43599&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=43599&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=43599&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=43599&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=43599&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=43599&r=mysqlcfg