#19156 [NEW]: Instanced COM-Ojects won't terminate if accessing array-properties
| From: | dwt at myrealbox dot com | Date: | Wed, 28 Aug 2002 16:31:19 +0000 |
| Subject: | #19156 [NEW]: Instanced COM-Ojects won't terminate if accessing array-properties | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-18053@lists.php.net to get a copy of this message | ||
From: dwt@myrealbox.com
Operating system: Windows XP
PHP version: 4.2.2
PHP Bug Type: COM related
Bug description: Instanced COM-Ojects won't terminate if accessing array-properties
When writing applications instancing COM objects I always faced the problem
of the instanced program not terminating correctly although everything
else worked fine. In fact the process had to be killed manually by using
the task manager. Browsing some messageboards I found out I was not the
only one and began to investigate the problem. I finally was able to
isolate the cause for this peculiar behaviour to be illustrated by the
sample code below:
<?php
//Accessing arrays by retrieving elements via function ArrayName(Index)
works, but certainly is neither efficient nor good style
$excel=new COM("Excel.Application");
$excel->sheetsinnewworkbook=1;
$excel->Workbooks->Add();
$book=$excel->Workbooks(1);
$sheet=$book->Worksheets(1);
$sheet->Name="Debug-Test";
$book->saveas("C:\\debug.xls");
$book->Close(false);
unset($sheet);
unset($book);
$excel->Workbooks->Close();
$excel->Quit();
unset($excel);
//Accessing arrays as usual (using the [] operator) works, buts leads to
the application not being able to terminate by itself
$excel=new COM("Excel.Application");
$excel->sheetsinnewworkbook=1;
$excel->Workbooks->Add();
$excel->Workbooks[1]->Worksheets[1]->Name="Debug-Test";
$excel->Workbooks[1]->saveas("C:\\debug.xls");
$excel->Workbooks[1]->Close(false);
$excel->Workbooks->Close();
$excel->Quit();
unset($excel);
?>
The sample code performs the same action twice and each time the file is
properly created. Yet for some mysterious reason the instanced excel
process won't terminate once you've accessed an array the way most
programmers (especially those who do a lot of oop in c++) do!
--
Edit bug report at http://bugs.php.net/?id=19156&edit=1
--
Try a CVS snapshot: http://bugs.php.net/fix.php?id=19156&r=trysnapshot
Fixed in CVS: http://bugs.php.net/fix.php?id=19156&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=19156&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=19156&r=needtrace
Try newer version: http://bugs.php.net/fix.php?id=19156&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=19156&r=support
Expected behavior: http://bugs.php.net/fix.php?id=19156&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=19156&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=19156&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=19156&r=globals