php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #35719 com_event_sink fails under Apache
Submitted: 2005-12-17 15:17 UTC Modified: 2005-12-17 19:58 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: csaba at alum dot mit dot edu Assigned: wez (profile)
Status: Wont fix Package: COM related
PHP Version: 5.1.1 OS: Win XP Pro
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: csaba at alum dot mit dot edu
New email:
PHP Version: OS:

 

 [2005-12-17 15:17 UTC] 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.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-12-17 19:58 UTC] wez@php.net
com_event_sink() and com_message_pump() are intended to be used in standalone, single-threaded processes.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Dec 12 17:01:31 2024 UTC