php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #42413 Cannot iterate IE's event object
Submitted: 2007-08-24 12:06 UTC Modified: 2020-02-06 16:31 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:0 (0.0%)
From: csaba at alum dot mit dot edu Assigned: cmb (profile)
Status: Not a bug Package: COM related
PHP Version: 5.2.3 OS: Win XP Pro
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: csaba at alum dot mit dot edu
New email:
PHP Version: OS:

 

 [2007-08-24 12:06 UTC] 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

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-08-24 12:17 UTC] jani@php.net
Assigned to the maintainer.
 [2014-12-30 05:51 UTC] kalle@php.net
-Status: Assigned +Status: Open -Assigned To: wharmby +Assigned To:
 [2020-02-06 16:31 UTC] cmb@php.net
-Status: Open +Status: Not a bug -Assigned To: +Assigned To: cmb
 [2020-02-06 16:31 UTC] cmb@php.net
In JavaScript you can iterate over the public properties of any
object. In PHP this works only if the object's isn't Traversable;
however, COM objects are.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Oct 11 15:01:27 2024 UTC