php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #43599 mem leak
Submitted: 2007-12-14 19:33 UTC Modified: 2008-01-29 00:11 UTC
From: ricardo dot saracino at seivu dot ca Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5.2.5 OS: Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: ricardo dot saracino at seivu dot ca
New email:
PHP Version: OS:

 

 [2007-12-14 19:33 UTC] ricardo dot saracino at seivu dot ca
Description:
------------
			
Last element or $data refers to the first $prod from the Product loop, memory reference problem just thought I?d 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] => 
                )

        )


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-01-29 00:11 UTC] tony2001@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.


 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Sat Jan 03 01:00:02 2026 UTC