#48512 [NEW]: DOMDocument::validate() fails with both a E_NOTICE and E_WARN if no DTD

From: Date: Tue, 09 Jun 2009 18:25:59 +0000
Subject: #48512 [NEW]: DOMDocument::validate() fails with both a E_NOTICE and E_WARN if no DTD
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-138153@lists.php.net to get a copy of this message
From: knut@php.net Operating system: Mac OS X 10.5.7 PHP version: 5.3CVS-2009-06-09 (CVS) PHP Bug Type: DOM XML related Bug description: DOMDocument::validate() fails with both a E_NOTICE and E_WARN if no DTD 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 -- Edit bug report at http://bugs.php.net/?id=48512&edit=1 -- Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=48512&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=48512&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=48512&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=48512&r=fixedcvs Fixed in CVS and need be documented: http://bugs.php.net/fix.php?id=48512&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=48512&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=48512&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=48512&r=needscript Try newer version: http://bugs.php.net/fix.php?id=48512&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=48512&r=support Expected behavior: http://bugs.php.net/fix.php?id=48512&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=48512&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=48512&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=48512&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=48512&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=48512&r=dst IIS Stability: http://bugs.php.net/fix.php?id=48512&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=48512&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=48512&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=48512&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=48512&r=mysqlcfg

« previous php.bugs (#138153) next »