|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #24474 domxml and threading issues
Submitted: 2003-07-03 04:33 UTC Modified: 2003-07-14 10:59 UTC
Avg. Score:3.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: grest at interia dot pl Assigned:
Status: Wont fix Package: DOM XML related
PHP Version: 4.3.2 OS: WinXp
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2003-07-03 04:33 UTC] grest at interia dot pl
get_element_by_id doesn`t work and always returns NULL.

Reproduce code:
<?xml version="1.0" encoding="UTF-8"?>


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2003-07-03 04:36 UTC]
Not enough information was provided for us to be able
to handle this bug. Please re-read the instructions at

If you can provide more information, feel free to add it
to this bug and change the status back to "Open".

Thank you for your interest in PHP.

 [2003-07-03 04:50 UTC] grest at interia dot pl
$fileName = "filmy.xml";
$fid = $HTTP_POST_VARS['deltitle'];
if(!$dom = domxml_open_file($fileName)) {
  echo "Error while parsing the document\n";
$node = $dom->get_element_by_id($fid);
$parent = $node->parent_node();
$delnode = $parent->remove_child($node);
$dom->dump_file("filmy.xml", true);
 [2003-07-03 04:57 UTC]
Please provide a FULL self-contained script which should work when we copy and paste it into a file and run it with php <filename>. This is useles.
 [2003-07-03 05:18 UTC] grest at interia dot pl
$fileName = "filmy.xml";
$fid = $HTTP_POST_VARS['deltitle'];
if(!$dom = domxml_open_file($fileName)) {
  echo "Error while parsing the document\n";
$node = $dom->get_element_by_id($fid);
$parent = $node->parent_node();
$delnode = $parent->remove_child($node);
$dom->dump_file("filmy.xml", true);
$filename = "filmy.xsl";
$xmldoc = domxml_open_file("filmy.xml");
$xsldoc = domxml_xslt_stylesheet_file($filename);
$result =  $xsldoc->process($xmldoc);
print $xsldoc->result_dump_mem($result);    

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE LIST SYSTEM "filmy.dtd">
<MOVIE ID="m20036271138360">
<TITLE>13 Duch?w</TITLE>
<MOVIE ID="m20036271138361">
<TITLE>8 kobiet</TITLE>
<LOC>Grzesiek HDD</LOC>

<form action="del.php" method="post" style="margin:0px">
<input type="hidden" name="deltitle" size="1" value="m20036271138360"><input type="image" name="Delete" src="del.gif">

I`m sure that 'deltitle' and $fid variable are correct "connected" (sorry for my English :P ), but get_element_by_id doesn`t find the node in XML file(filmy.xml)
 [2003-07-03 05:26 UTC]
Your xml is not valid:

# /usr/bin/xmllint filmy.xml 
filmy.xml:5: error: Input is not proper UTF-8, indicate encoding !
<TITLE>13 Duch?w</TITLE>
filmy.xml:5: error: Bytes: 0xF3 0x77 0x3C 0x2F
<TITLE>13 Duch?w</TITLE>

 [2003-07-03 06:04 UTC] grest at interia dot pl
I`ve checked this out, and this is not the reason.
 [2003-07-04 05:05 UTC] grest at interia dot pl
I replaced the polish characters with normal character, but it still doesn`t work.
 [2003-07-04 09:03 UTC]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at and the instructions on how to report
a bug at

open the file using domxml_open_file($fileName, DOMXML_LOAD_VALIDATING) in order to process the DTD
 [2003-07-04 10:06 UTC] grest at interia dot pl
Thanks, now it works correct :) I didn`t find in the manual the information about DOMXML_LOAD_VALIDATING.
 [2003-07-04 10:07 UTC]
Making it a documentation problem then.
 [2003-07-04 10:08 UTC]
still not a bug.. So it should be marked bogus. 
 [2003-07-04 10:10 UTC]
ops.. we are editing bugs at the same time.. 
 [2003-07-09 07:44 UTC] grest at interia dot pl
I have installed PHP as Apache 2.0.46 module (earlier i used OmniHttp). That caused two problems:
1. The functions like domxml_open_file,domxml_xslt_stylesheet_file need now full path to work, for example
      $filename = "d:\Www\grugar\filmy.xsl";
	$xmldoc = domxml_open_file("d:\Www\grugar\filmy.xml",DOMXML_LOAD_VALIDATING);

earlier it works fine with  $filename = "filmy.xsl"

Another function like "fopen" work good without full path

get_element_by_id stoped working, and return always null
(earlier with OmniHttp that works fine)

Is this a bug or not? I don`t know, which category of bug should i choose.
Sorry for my English :)
 [2003-07-09 08:02 UTC]
Using Apache under windows you must use fullpath names with domxml. All filepaths are handled by libxml (not PHP) which when loaded uses the apache bin directory as the root directory. This includes the path to the DTD within your xml document, which is the reason that get_element_by_id is not working, as the DTD is not being loaded.
 [2003-07-09 14:07 UTC] grest at interia dot pl
Little mistake in line 5. Once again:
I try various path in filmy.xml to dtd file, like:
<!DOCTYPE LIST SYSTEM "D:\WWW\grugar\filmy.dtd">
<!DOCTYPE LIST SYSTEM "D:/WWW/grugar/filmy.dtd">
<!DOCTYPE LIST SYSTEM "\\Serwer\WWW\grugar\filmy.dtd">
<!DOCTYPE LIST SYSTEM "d:/www/grugar/filmy.dtd">
and none of them works !!
How should this path look?!
For example the path in XSL file (filmy.xsl) works:
<xsl:variable name="out" select="document('d:/www/grugar/today.xml')"/>
 [2003-07-09 14:55 UTC]
Works fine using syntax: "d:/www/grugar/filmy.dtd" or just "filmy.dtd".  Looks like some pathing got fixed with apache 2.

Unless you give full path for the save location, your output file will end up in Apache root directory.

Are you sure that you are getting NULL back from get_element_by_id or is the problem that you just dont get your output file?
 [2003-07-09 18:19 UTC] grest at interia dot pl
When I use in XSL file(filmy.xsl) just 	 	
<xsl:variable name="out" select="document('today.xml')"/>
it works fine. 
I needn`t to insert a full path('d:\www\grugar\today.xml')

In XML it doesn`t work.
I use:
<!DOCTYPE LIST SYSTEM "filmy.dtd">
<!DOCTYPE LIST SYSTEM "d:/www/grugar/filmy.dtd">

and always when I use get_element_by_id, I get a NULL!
I`m sure that XML is not validated with filmy.dtd.
I tested XML with two identical id (without error while loading!) or insert a mistakes into filmy.dtd and the domxml_open_file($fileName, DOMXML_LOAD_VALIDATING)does NOT return any errors or warnings. Conclusion: "filmy.dtd" is not loaded.
Earlier, in similar case domxml_open_file returns error.
 [2003-07-10 06:09 UTC]
can you provide the output from phpinfo either as a link to it or via email. Make sure it is run under apache and run from the same directory as your example is.
 [2003-07-11 06:14 UTC]
Changed summary as this is just a symptom of threading issues.

When running in a multi-threaded environment AND libxml is using threads, the extensions behavior can not be predicted when using functions involving libxml globals. This includes functions not working as expected, inconsistent function behavior and possible crashes.

Workaround: Run under CGI mode or use libxml without thread support.

Suspending this for now
 [2003-07-14 10:59 UTC]
This is not an issue with the new xml extensions in PHP5 where domxml is replaced by the dom and xsl extensions
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Jun 19 15:01:31 2024 UTC