From: boccara at netvision dot net dot il
Operating system: win 2K / apache 2.0.49
PHP version: 4.3.9
PHP Bug Type: Reproducible crash
Bug description: Error message: Call to a member function on a non-object
Description:
------------
Hello I have a defined a class that manage a 2 dimensions array (table).
I have created 2 oblect of this class.
These oblect are inside a loop , a fetch from an sql query (MSSQL).
The oblects received data from the query.
Teh problem is that after a certain number of times in the loop ( always
the same number of times depending to the query), I got an error message:
Call to a member function on a non-object
when are called the function of the created object.
This is very strange, the created object seems to be deleted !!
I use Zend Studio, I use the debugger to search the bug, but there is no
syntax bug or anything else !?
Reproduce code:
---------------
class TotDevisParEditeur
{
var $VecEditeur = array();
var $value = array();
function GetValue($type,$editeur)
{
return $this->VecEditeur[$editeur][$type];
}
function Display($type,$editeur)
{
echo $this->VecEditeur[$editeur][$type];
endl();
}
function AddDevis($type,$editeur,$numOfdevis)
{
$value[$type] = $this->GetValue($type,$editeur) + $numOfdevis;
$this->VecEditeur[$editeur] = $value;
$this->Display($type,$editeur);
}
}
/////////////////////////////////////////////////////////
$SousTotal = new TotDevisParEditeur;
$SousTotalCom = array();
$SousTotalCom['gagne'] = new TotDevisParEditeur;
$SousTotalCom['perdu'] = new TotDevisParEditeur;
$SousTotalCom['encours'] = new TotDevisParEditeur;
while (dbFetch($iTableTmp, $Col))
{
/*
in this portion of code there is no redefinition of the object !!
just value are assigned to $RefEditeur, $Gagne,...
*/
$SousTotal->AddDevis('gagne',$RefEditeur,$Gagne);
$SousTotal->AddDevis('perdu',$RefEditeur,$Perdu);
$SousTotal->AddDevis('encours',$RefEditeur,$Encours);
$SousTotalCom['gagne']->AddDevis($Gestionnaire,$RefEditeur,$Gagne);
$SousTotalCom['perdu']->AddDevis($Gestionnaire,$RefEditeur,$Perdu);
$SousTotalCom['encours']->AddDevis($Gestionnaire,$RefEditeur,$Encours);
}
Expected result:
----------------
.... results .....
************************************
0000010215-------VR------>
0
0
2
6---- VR ------>
0
0
2
************************************
0000010215-------CA2------>
0
0
1
6---- CA2 ------>
2
0
1
************************************
0000010215-------VR------>
0
0
1
6---- VR ------>
0
0
3
************************************
0000008896-------VR------>
************************
instead of the error it should continue !!!!!!!!!!!!
*************************
Actual result:
--------------
last section of the result
************************************
0000010215-------VR------>
0
0
2
6---- VR ------>
0
0
2
************************************
0000010215-------CA2------>
0
0
1
6---- CA2 ------>
2
0
1
************************************
0000010215-------VR------>
0
0
1
6---- VR ------>
0
0
3
************************************
0000008896-------VR------>
Fatal error: Call to a member function on a non-object in c:\Program
Files\Apache Group\Apache2\htdocs\speedevis\lib\StatRev.inc.php on line
2018
--
Edit bug report at http://bugs.php.net/?id=30630&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=30630&r=trysnapshot4
Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=30630&r=trysnapshot50
Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=30630&r=trysnapshot51
Fixed in CVS: http://bugs.php.net/fix.php?id=30630&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=30630&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=30630&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=30630&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=30630&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=30630&r=support
Expected behavior: http://bugs.php.net/fix.php?id=30630&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=30630&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=30630&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=30630&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=30630&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=30630&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=30630&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=30630&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=30630&r=float
MySQL Configuration Error: http://bugs.php.net/fix.php?id=30630&r=mysqlcfg