ID: 34463
User updated by: csaba at alum dot mit dot edu
Reported By: csaba at alum dot mit dot edu
-Status: Open
+Status: Bogus
Bug Type: Scripting Engine problem
PHP Version: 5CVS-2005-09-11 (snap)
New Comment:
My apologies. When you stare at $newCom and $newCOM they sometimes
look the same, but they aren't.
Csaba
PS. Sniper: now this report is one you could corrupt!
Previous Comments:
------------------------------------------------------------------------
[2005-09-11 14:40:50] csaba at alum dot mit dot edu
Description:
------------
If I do eval('$com=new COM("WScript.Shell");');
then gettype($com) is the empty string
while com_print_typeinfo($com) leads to the CLI / Apache error dialog
box asking whether I want to send Microsoft a report about it.
Nevertheless, the $com object is (at least somewhat) valid because I
can subsequently (if I didn't do a com_print_typeinfo) do other things
with it. Thus, gettype is incorrect, and com_print_typeinfo should not
crash PHP.
Csaba Gabor from Vienna
PS. Uncomment any of the 3 new COM lines, and it runs
as expected.
Marked as a Scripting Engine Problem since the
problem seems to start in the eval line.
Reproduce code:
---------------
<?php
print "<pre>\n";
$oEnv = newCOM("WScript.Shell")->Environment("process");
foreach ($oEnv as $idx=>$val) print "$idx: $val\n";
print "</pre>";
function newCOM($comSpec) {
$eval = '$newCom = new COM("' . $comSpec . '");';
print ("going to eval: $eval\n");
try { eval($eval); }
catch (Exception $e) {
output("Could not load COM: $comSpec"); return null; }
//$newCOM = new COM("WScript.Shell");
//$newCOM = new COM(&$comSpec);
//$newCOM = new COM($comSpec);
print "newCOM has gettype: " . gettype($newCOM) . "\n";
print " typename: " . typename($newCOM) . "\n\n";
com_print_typeinfo($newCOM);
return $newCom;
}
function typename($objCOM) {
if (is_null($objCOM)) return null;
$oScript = new COM("MSScriptControl.ScriptControl");
$oScript->language = "VBScript";
$oScript->addObject("objCom",$objCOM);
return $oScript->eval("typename(objCom)");
}
?>
Expected result:
----------------
After the 'going to eval' line, I expect to see:
newCOM has gettype: object
typename: IWshShell3
Actual result:
--------------
newCOM has gettype: NULL
typename:
followed by a PHP crash
If you remove the com_print_typeinfo line, the rest of the code
executes as expected. In other words, the COM object functions so the
gettype is still wrong.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=34463&edit=1