php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #48512 DOMDocument::validate() fails with both a E_NOTICE and E_WARN if no DTD
Submitted: 2009-06-09 18:25 UTC Modified: 2009-06-15 12:22 UTC
From: knut@php.net Assigned: iliaa (profile)
Status: Closed Package: DOM XML related
PHP Version: 5.3CVS-2009-06-09 (CVS) OS: Mac OS X 10.5.7
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: knut@php.net
New email:
PHP Version: OS:

 

 [2009-06-09 18:25 UTC] knut@php.net
Description:
------------
The TestFest seems to be working :) Just found a strange behavior in DOMDocument::validate(). If no DTD is given you'll both have a E_NOTICE and a E_WARN saying pretty much the same. Looking at the implementation it seems like PHP tries to define this behavior as a E_NOTICE, while it will fail in libxml as a E_WARN.

I would expect this method to raise just one of the error messages, not both.

The E_NOTICE is raised in line 1941 in ext/dom/document.c


Reproduce code:
---------------
<?php
$xml = "<?xml version=\"1.0\"?>
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend</body>
</note>";
$dom = new DOMDocument('1.0');
$dom->loadXML($xml);
var_dump($dom->validate());
?>

Expected result:
----------------
Warning: DOMDocument::validate(): no DTD found! in %s on line 11

Actual result:
--------------
Notice: DOMDocument::validate(): No DTD given in XML-Document in %s on line 11

Warning: DOMDocument::validate(): no DTD found! in %s on line 11


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-06-15 12:22 UTC] iliaa@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sat May 03 01:01:29 2025 UTC