php.net |  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
Votes:3
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
Description:
------------
get_element_by_id doesn`t work and always returns NULL.

Reproduce code:
---------------
MY DTD:
<?xml version="1.0" encoding="UTF-8"?>
<!ELEMENT LIST (MOVIE+)>
<!ELEMENT MOVIE (TITLE, ORGTITLE, LOC, INFO)>
<!ATTLIST MOVIE
	ID ID #REQUIRED
>
<!ELEMENT TITLE (#PCDATA)>
<!ELEMENT ORGTITLE (#PCDATA)>
<!ELEMENT LOC (#PCDATA)>
<!ELEMENT INFO (#PCDATA)>



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

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

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";
  exit;
}
$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] derick@php.net
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
del.php
<?php
$fileName = "filmy.xml";
$fid = $HTTP_POST_VARS['deltitle'];
if(!$dom = domxml_open_file($fileName)) {
  echo "Error while parsing the document\n";
  exit;
}
$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);    
?>

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

simply.html:
<html>
<body>
<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">
</form>
</body>
</html>

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] sniper@php.net
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] rrichards@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

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] derick@php.net
Making it a documentation problem then.
 [2003-07-04 10:08 UTC] magnus@php.net
still not a bug.. So it should be marked bogus. 
 [2003-07-04 10:10 UTC] magnus@php.net
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

2. (MOST IMPORTANT)
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] rrichards@php.net
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:
filmy.xsl
...
<xsl:variable name="out" select="document('d:/www/grugar/today.xml')"/>
...
 [2003-07-09 14:55 UTC] rrichards@php.net
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">
or 
<!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] rrichards@php.net
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] rrichards@php.net
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] rrichards@php.net
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-2019 The PHP Group
All rights reserved.
Last updated: Mon Dec 16 09:01:29 2019 UTC