php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #26531 get_elements_by_tag_name() wildcard fails
Submitted: 2003-12-05 06:38 UTC Modified: 2003-12-05 14:20 UTC
From: jon at hiveminds dot net Assigned:
Status: Closed Package: DOM XML related
PHP Version: 4.3.4 OS: Windows 2000 / SP4
Private report: No CVE-ID: None
 [2003-12-05 06:38 UTC] jon at hiveminds dot net
Description:
------------
The use of a wildcard with the get_elements_by_tagname() method to obtain a collection of all DomElement nodes in a document appears to be broken in PHP4.3.4 for Windows. Rather than returning an array, it returns NULL. Upgrading broke numerous scripts depending on this behaviour, which reverted to normal as soon as I rolled back to 4.3.3.

The use of "*" as a wildcard in this fashion is per the W3C DOM spec, and performed as expected in PHP4.3.0-4.3.3 / win32.

Extensions enabled: cpdf, ctype, curl, domxml, gd2, iconv, ming, pdf, pgsql, xslt, yaz, zip

Versions of libxml, libxslt, and iconv used were those supplied in the distributions downloaded from php.net.

Server: IIS/5.0

The only other apps installed on this system are: MySQL 4.1-alpha, ActivePython-2.2.2-224, ActivePerl-5.8.1.807, MSIE 5.0, MSXML 4.0

Reproduce code:
---------------
<?php
  //  Used 2 small XML files which are known 
  //  to be well-formed; domxml_open_file() succeeds
  //  in both cases

  if( !$map = domxml_open_file( realpath("xml/map.xml") ) )
    return;
  
  $alltags = $map->get_elements_by_tagname("*");
  
  echo count($alltags) . "<br>";
  echo (is_array($alltags) ? "ARRAY" : "NOT ARRAY") . "<br>";
  echo $alltags === NULL ? "NULL" : "NOT NULL";
?>

Expected result:
----------------
Script output under PHP 4.3.3:

138
ARRAY
NOT NULL

69
ARRAY
NOT NULL

The XML files used contain 138 and 69 tags each (counting the document root), so these are correct. Both files were generated using DOMXML DomDocument->dump_file(real_path("path/to/file.xml"), FALSE, FALSE).

Actual result:
--------------
Same script and XML files under PHP 4.3.4:

0
NOT ARRAY
NULL

0
NOT ARRAY
NULL


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-12-05 14:20 UTC] rrichards@php.net
This bug has been fixed in CVS.

In case this was a PHP problem, snapshots of the sources are packaged
every three hours; this change will be in the next snapshot. You can
grab the snapshot at http://snaps.php.net/.
 
In case this was a documentation problem, the fix will show up soon at
http://www.php.net/manual/.

In case this was a PHP.net website problem, the change will show
up on the PHP.net site and on the mirror sites in short time.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 16 14:01:29 2024 UTC