Bug #42413 [Asn->Opn]: Cannot iterate IE's event object
| From: | kalle@php.net | Date: | Tue, 30 Dec 2014 05:51:07 +0000 |
| Subject: | Bug #42413 [Asn->Opn]: Cannot iterate IE's event object | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-189332@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=42413&edit=1
ID: 42413
Updated by: kalle@php.net
Reported by: csaba at alum dot mit dot edu
Summary: Cannot iterate IE's event object
-Status: Assigned
+Status: Open
Type: Bug
Package: COM related
Operating System: Win XP Pro
PHP Version: 5.2.3
-Assigned To: wharmby
+Assigned To:
Block user comment: N
Private report: N
Previous Comments:
------------------------------------------------------------------------
[2007-08-24 12:17:24] jani@php.net
Assigned to the maintainer.
------------------------------------------------------------------------
[2007-08-24 12:06:04] csaba at alum dot mit dot edu
Description:
------------
I can't iterate over IE's $ie->document->createEventObject() with PHP whereas I can
in IE.
Reproduce code:
---------------
<?php
// create a new internet explorer instance
$ie = new COM("InternetExplorer.Application");
// So the alerts can be seen
$ie->visible = true;
// ensure a document exists within ie
$ie->Navigate2 ("about:blank");
while ($ie->readyState!=4) usleep(100000);
// convenience
$doc = $ie->document;
$window = $doc->parentWindow;
// required - var must be declared
$window->execScript ("var evt='';");
// create an event object
$window->evt = $doc->createEventObject();
// proof the object is valid, iteratable
$window->execScript("
var str=''; var idx;
for (idx in evt)
str+=idx+'; ';
alert('Keys: '+str);");
// Bug: can't iterate the object in PHP
foreach ($window->evt as $prop => $val)
print "<br>$prop ";
// ensure ie is still alive
$window->execScript("alert('Alive');");
$ie->quit(); // necessary since visible
?>
Expected result:
----------------
I expect PHP not to die at the foreach
I expect the same text to be output as with the alert
Actual result:
--------------
PHP falls over upon hitting the foreach loop with:
Fatal error: Uncaught exception 'Exception' with message 'Object of type variant did
not create an Iterator' in c:\phpBugs\foreach.php: 28
Stack trace:
#0 C:\phpBugs\foreach.php(28): unknown()
#1 {main} thrown in C:\phpBugs\foreach.php on line 28
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=42413&edit=1