From:             csaba at alum dot mit dot edu
Operating system: WinXP Pro
PHP version:      5.1.1
PHP Bug Type:     COM related
Bug description:  IE event failure upon scheduling script

Description:
------------
My script brings up an instance of IE, and then it places onto IE a
function that will execute one of the script's functions (within the
script's environment).  This is a normal scenario usually achieved through
com_event_sink in PHP.  However, I have implemented this independent of
events.  I have both a VB and PHP version, both are working fine from the
command line, thanks very much.

The problem is that when I run the PHP version using the scheduler (either
AT or SchTask), I get an IE error IE right at the point that it tries to
call back into the script (a permissions issue?).  The scheduled VB
version works fine, and if I schedule PHP to invoke the VB version that
works just fine, too.

Csaba Gabor from Vienna

Reproduce code:
---------------
<?php
$ie = new COM("InternetExplorer.Application");  // new IE
$ie->visible = true;
$ie->Navigate2("about:blank");              // empty DOM
while ($ie->readyState<4) usleep(10000);    // wait for IE
$window =$ie->document->parentWindow;
$window->execScript("window.doneP=false");  // init var

$oScript=new COM("MSScriptControl.ScriptControl"); 
$oScript->Language = "VBScript";
$oScript->AddCode('Sub EvtWrapper()
    CreateObject("WScript.Shell").Popup _
      "ScriptControl reached", 4, "WScript popup", 131120
    End Sub');

$oScript->AddObject ("mydoc", $ie->document);
$oScript->ExecuteStatement(
    'mydoc.onclick=GetRef("EvtWrapper")');
$window->execScript(
    "window.myfunc=window.document.onclick");

$window->setTimeout("window.myfunc()",100);

mypopup("At com_message_pump");
try { while (!$window->doneP) com_message_pump(500); }
catch (Exception $e) { popup ("In the catch"); }
mypopup ("Done with script");

function mypopup ($text) {
   $oWSH = new COM("WScript.Shell");
   $oWSH->Popup($text, 4, "PHP Popup", 131120); }
?>

Expected result:
----------------
I expect this script, schTest.php, to not error when it is scheduled with
AT as:
AT 14:10 %comspec% "/K php c:\path\to\schTest.php"

In particular, just as when it is run directly, IE should come up, and
then there should be two popups: "At com_message_pump" followed by
"ScriptControl reached".  Once IE is dismissed, there should be two more
popups: "In the catch" and "Done with script"

Actual result:
--------------
When SchTest.php is run directly (or via a .vbs invocation) then all four
popups show normally.  However, when schTest.php is scheduled through AT,
then there is an IE error saying
Line: 0
Error: Object doesn't support this property or method.

When I try the scheduling through SchTask (same results as with AT), then
it is scheduled as NT AUTHORITY\SYSTEM (no password).  I'm the only user
on my system and since I don't have a password, I haven't figured out how
to schedule tasks to run under my user name.

I am happy to provide the corresponding VBScript code if it would be
helpful.

-- 
Edit bug report at http://bugs.php.net/?id=35875&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=35875&r=trysnapshot44
Try a CVS snapshot (PHP 5.1): 
http://bugs.php.net/fix.php?id=35875&r=trysnapshot51
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=35875&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=35875&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=35875&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=35875&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=35875&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=35875&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=35875&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=35875&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=35875&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=35875&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=35875&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=35875&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=35875&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=35875&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=35875&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=35875&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=35875&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=35875&r=mysqlcfg

Reply via email to