#29973 [NoF->Opn]: Comparing COM object variable with NULL throws an exception
| From: | tetikr at spytech dot cz | Date: | Fri, 25 Mar 2005 08:28:08 +0000 |
| Subject: | #29973 [NoF->Opn]: Comparing COM object variable with NULL throws an exception | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-75849@lists.php.net to get a copy of this message | ||
ID: 29973
User updated by: tetikr at spytech dot cz
Reported By: tetikr at spytech dot cz
-Status: No Feedback
+Status: Open
Bug Type: COM related
-Operating System: Win2000
+Operating System: Win2003
-PHP Version: 5.0.1
+PHP Version: 5.0.3
Assigned To: wez
New Comment:
The problem is still there. Testing a COM object created by the new
operator or return by a COM property/method on NULL throws an exception
"Member not found.".
Using the is_object() function helps, but it is inconvenient and ugly.
Let's make PHP better :-)
Previous Comments:
------------------------------------------------------------------------
[2005-03-25 01:55:26] sniper@php.net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.
------------------------------------------------------------------------
[2005-03-19 21:49:35] sniper@php.net
Please try using this CVS snapshot:
http://snaps.php.net/php5-latest.tar.gz
For Windows:
http://snaps.php.net/win32/php5-win32-latest.zip
------------------------------------------------------------------------
[2004-09-09 21:25:51] wez@php.net
in this case you should be doing:
try {
$a = new COM(...);
// use it here
} catch (exception $e) {
// failed to create it
}
in other cases, where you have been passed the object, use is_object()
to check if it is valid.
I'll see if I can fix the shorthand "if (!$a)" syntax someone in the
next month.
------------------------------------------------------------------------
[2004-09-06 14:27:03] tetikr at spytech dot cz
Some objects work and some not. The following code creates an object
that works not. It throws a COM exception "Member not found". Test it
for yourself, I hope it will fail :-)
---------------------------------
$o = new COM("WScript.Shell");
if (!$o)
/* dummy */ ;
else
echo $o->CurrentDirectory;
---------------------------------
------------------------------------------------------------------------
[2004-09-06 08:06:19] derick@php.net
What is the full error message?
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/29973
--
Edit this bug report at http://bugs.php.net/?id=29973&edit=1