ID:               35719
 Updated by:       [EMAIL PROTECTED]
 Reported By:      csaba at alum dot mit dot edu
-Status:           Assigned
+Status:           Wont fix
 Bug Type:         COM related
 Operating System: Win XP Pro
 PHP Version:      5.1.1
 Assigned To:      wez
 New Comment:

com_event_sink() and com_message_pump() are intended to be used in
standalone, single-threaded processes.


Previous Comments:
------------------------------------------------------------------------

[2005-12-17 15:17:04] csaba at alum dot mit dot edu

Description:
------------
Using com_event_sink when PHP 5.1.1 runs as a module leads to PHP
timing out and generating an ugly apache error.

I want to be able to start up IE as a COM object and load a page into
it so that I may parse the page.  This makes sense because page
scraping (ie, using the contents returned by file_get_contents($url) or
other means) is not always tenable since scripts may substantially alter
the page.  It is reasonable to wait for the page to load before starting
to deal with it, hence the need for com_event_sink.

If the below code is run as CLI PHP, then it works just fine: Run the
script, see an IE window come up, and then close that IE window to
terminate the script.  You can get a record of what happened in the
file 'log' in the same directory as the script.

To see the bug, invoke the php file via a web server (I have been using
localhost/phpapp/theScript.php).  The IE window will come up and php.net
will be loaded, but the last entry showing in the log file is:
com_event_sink has been called

Whether or not the IE window is closed, the script will time out and an
Apache HTTP Server error comes up apologizing for the inconvenience and
asking whether I'd like to tell Microsoft about the problem.

Csaba Gabor from Vienna

Reproduce code:
---------------
<html><head><title>com_event_sink test page</title></head><body>
<?php 
$logFile = preg_replace("/[^\\/\\\\]+$/",
                        "log",__FILE__);
file_put_contents($logFile, "");
logit("Entered at: " . date("H:i:s, j M Y   e"));
logit("Script: " . __FILE__);

function logit($out) {
    print "$out<br>\n";
    file_put_contents($GLOBALS['logFile'],
        "$out\n", FILE_APPEND); }

class IESink { 
    public $terminated = false;
    public function TitleChange($text) { 
        logit ("title has changed: $text"); }

    public function DocumentComplete (&$dom, $url) {
        logit ("doc has loaded: $url"); }

    public function OnQuit() { 
        logit ("Quitting");
        $this->terminated = true; } }

$ie = new COM("InternetExplorer.Application"); 
$ie->Visible = true; 
$url = "http://php.net";;
$ie->Navigate($url);

$sink = new IESink;
logit ("About to sink");
com_event_sink($ie, $sink, "DWebBrowserEvents2"); 
logit ("com_event_sink has been called");

while (!$sink->terminated) {
    com_message_pump(1000); }

logit ("finished!");
?>
</body></html>

Expected result:
----------------
I expect to see events fire even when IE is brought up while it is
invoked under a web server.

Actual result:
--------------
IE Events don't fire, and there is an ugly error when PHP times out.


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=35719&edit=1

Reply via email to