#47833 [NEW]: xpath::query fails when huge xml file loaded

[email protected] ("getmequick at gmail dot com")
Newsgroups php.bugs
Message-ID <[email protected]>
From:             getmequick at gmail dot com
Operating system: Windows XP
PHP version:      5.2.9
PHP Bug Type:     DOM XML related
Bug description:  xpath::query fails when huge xml file loaded

Description:
------------
I'm running latest PHP 5.2.9.1 on Win XP machine with apache 2.0 on it

I have 1GB free RAM (of 2GB)

here's the issue, I load huge xml file (8MB) that has namespace defined in
it and try query with xpath, it ends with timeout error

strangely, when I move namespace definition out, it works. 
also, if I reduce filesize to say 1KB it also works (with namespace
defined)

summary:

- Doesn't work when xml has a namespace defined and filesize is huge (~8MB
tested)

- Works when filesize is tiny and has a namespace.
- Works when filesize is huge and no namespace defined.


Reproduce code:
---------------
test.xml
------------------
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.google.com/schemas/sitemap/0.84">
<url>
<loc>..</loc>
</url>
<url>
<loc>..</loc>
</url>
<url>
<loc>..</loc>
</url>
</urlset>


test.php
------------------
<?php
ini_set('display_errors', true);
ini_set('error_reporting', E_ALL);

$dom     = DomDocument::load('test.xml');
$xpath   = new DomXPath($dom);
$ns    = '';
if ($dom->documentElement && $dom->documentElement->namespaceURI)
{
  $xpath->registerNamespace('ns', $dom->documentElement->namespaceURI);
  $ns    = 'ns:';
}

$locUrls  = $xpath->query("//{$ns}loc");
var_dump($locUrls);
?>

Expected result:
----------------
Nodelist object.

Actual result:
--------------
PHP timeout error.

-- 
Edit bug report at http://bugs.php.net/?id=47833&edit=1
-- 
Try a CVS snapshot (PHP 5.2):        http://bugs.php.net/fix.php?id=47833&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):        http://bugs.php.net/fix.php?id=47833&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):        http://bugs.php.net/fix.php?id=47833&r=trysnapshot60
Fixed in CVS:                        http://bugs.php.net/fix.php?id=47833&r=fixedcvs
Fixed in CVS and need be documented: http://bugs.php.net/fix.php?id=47833&r=needdocs
Fixed in release:                    http://bugs.php.net/fix.php?id=47833&r=alreadyfixed
Need backtrace:                      http://bugs.php.net/fix.php?id=47833&r=needtrace
Need Reproduce Script:               http://bugs.php.net/fix.php?id=47833&r=needscript
Try newer version:                   http://bugs.php.net/fix.php?id=47833&r=oldversion
Not developer issue:                 http://bugs.php.net/fix.php?id=47833&r=support
Expected behavior:                   http://bugs.php.net/fix.php?id=47833&r=notwrong
Not enough info:                     http://bugs.php.net/fix.php?id=47833&r=notenoughinfo
Submitted twice:                     http://bugs.php.net/fix.php?id=47833&r=submittedtwice
register_globals:                    http://bugs.php.net/fix.php?id=47833&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=47833&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=47833&r=dst
IIS Stability:                       http://bugs.php.net/fix.php?id=47833&r=isapi
Install GNU Sed:                     http://bugs.php.net/fix.php?id=47833&r=gnused
Floating point limitations:          http://bugs.php.net/fix.php?id=47833&r=float
No Zend Extensions:                  http://bugs.php.net/fix.php?id=47833&r=nozend
MySQL Configuration Error:           http://bugs.php.net/fix.php?id=47833&r=mysqlcfg
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.