php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #47833 xpath::query fails when huge xml file loaded
Submitted: 2009-03-29 20:41 UTC Modified: 2009-04-21 01:00 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: getmequick at gmail dot com Assigned:
Status: No Feedback Package: DOM XML related
PHP Version: 5.2.9 OS: Windows XP
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: getmequick at gmail dot com
New email:
PHP Version: OS:

 

 [2009-03-29 20:41 UTC] getmequick at gmail dot com
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.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-04-13 18:27 UTC] jani@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows:

  http://windows.php.net/snapshots/


 [2009-04-21 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jan 02 12:01:29 2025 UTC