|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #70556 The parser reports duplicate id's when there are none.
Submitted: 2015-09-23 05:27 UTC Modified: 2018-08-26 17:00 UTC
From: chauvaux at crestec dot co dot jp Assigned: cmb (profile)
Status: No Feedback Package: DOM XML related
PHP Version: 5.5.29 OS: Windows 2008
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: chauvaux at crestec dot co dot jp
New email:
PHP Version: OS:


 [2015-09-23 05:27 UTC] chauvaux at crestec dot co dot jp
Bug report

PHP: versions 5.5.24 and up (working as an Apache module
on a window box, and installed with XAMPP)
Module: XML DOM 
Method: load()

We are handling large XML documents (books). To make things easier to read,
we use a main XML document with the doctype header and a list of entity
declarations (one per chapter). The main XML document body is just a list of
entity references. Then we have separate files for each chapter.

Problem: when trying to load the main file, the parser reports duplicate id
values. It seems that the parser registers the values of the id attribute 
at the time it reads the entity declaration, and again when it actually 
imports the contents of the entity file.

NOTE: this problem did not occurred with version up to 5.5.23. It started at
version 5.5.24 and is still there at version 5.5.29.

To make things easier to whoever will be kind enough to try to fix this
bug, we have prepared 3 small files:

domtest.xml is the main file that we want to load in to the DOM object.
file_01.xml is the contents of one chapter.
domload.php is a small script that will allow you to replicate the error.

Thank you very much for your help.

Test script:
Filename: domtest.xml: the main XML file to load

<?xml version='1.0' encoding='UTF-8'?>
<!--simple dtd for the purpose of this test-->
<!DOCTYPE book [ 
<!ELEMENT book (chapter)+ >
<!ELEMENT chapter (para)* >

<!--entity declaration for one chapter; 
a real book would contain many of them-->
<!ENTITY file_01 SYSTEM "file_01.xml">

<!--entity reference; 
a real book would contain many of them-->

Filename: file_01.xml:

<para id='id_010'>aaa</para>
<para id='id_011'>bbb</para>



$dom = new DOMDocument();
$dom->resolveExternals = true;
$dom->substituteEntities = true;

$result = $dom->load('domtest.xml');

Expected result:
Since no id is replicated, a warning should not appear.

Actual result:
A warning telling that there are duplicate id's.
The file however loads correctly.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2018-08-10 12:13 UTC]
-Status: Open +Status: Feedback -Assigned To: +Assigned To: cmb
 [2018-08-10 12:13 UTC]
While I can reproduce this with PHP 5.6.15 with libxml 2.9.2, I
can't with PHP 7.0.18 with libxml 2.9.4 nor with recent master and
libxml 2.9.8 (all Windows 10).  Since active support for PHP 5
ended long ago, it seems this ticket can be closed, unless
somebody else can reproduce it with any actively supported PHP

[1] <>
 [2018-08-26 17:00 UTC]
-Status: Feedback +Status: No Feedback
 [2018-08-26 17:00 UTC]
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Jul 22 04:01:29 2024 UTC