#26531 [NEW]: get_elements_by_tag_name() wildcard fails

From: Date: Fri, 05 Dec 2003 11:38:59 +0000
Subject: #26531 [NEW]: get_elements_by_tag_name() wildcard fails
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-51723@lists.php.net to get a copy of this message
From: jon at hiveminds dot net Operating system: Windows 2000 / SP4 PHP version: 4.3.4 PHP Bug Type: DOM XML related Bug description: get_elements_by_tag_name() wildcard fails 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 -- Edit bug report at http://bugs.php.net/?id=26531&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=26531&r=trysnapshot4 Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=26531&r=trysnapshot5 Fixed in CVS: http://bugs.php.net/fix.php?id=26531&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=26531&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=26531&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=26531&r=needscript Try newer version: http://bugs.php.net/fix.php?id=26531&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=26531&r=support Expected behavior: http://bugs.php.net/fix.php?id=26531&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=26531&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=26531&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=26531&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=26531&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=26531&r=dst IIS Stability: http://bugs.php.net/fix.php?id=26531&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=26531&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=26531&r=float

« previous php.bugs (#51723) next »