Doc #55184 [NEW]: DOMDocument::load() throws an exception instead of returning false on error
| From: | stuart at horuskol dot net | Date: | Tue, 12 Jul 2011 02:14:39 +0000 |
| Subject: | Doc #55184 [NEW]: DOMDocument::load() throws an exception instead of returning false on error | ||
| Groups: | php.doc.bugs | ||
| Request: | Send a blank email to doc-bugs+get-6864@lists.php.net to get a copy of this message | ||
From:
Operating system:
PHP version: Irrelevant
Package: Documentation problem
Bug Type: Documentation Problem
Bug description:DOMDocument::load() throws an exception instead of returning false on error
Description:
------------
---
From manual page: http://www.php.net/domdocument.load%23Errors/Exceptions
---
The manual page reports that this method returns false on failure -
however, testing this function has resulted in exceptions being thrown
instead.
Can the manual be updated to reflect this?
Test script:
---------------
Example XML files:
http://horuskol.net/media/php/map-not-xml.xml
http://horuskol.net/media/php/map-malformed-xml.xml
<?php
$dom = new DOMDocument();
try {
if (!$dom->load('not-a-file')) {
throw new Exception('Error loading source file');
}
} catch (Exception $e) {
echo $e->getMessage();
}
try {
if (!$dom->load('map-not-xml.xml')) {
throw new Exception('Error loading source file');
}
} catch (Exception $e) {
echo $e->getMessage();
}
try {
if (!$dom->load('map-malformed-xml.xml')) {
throw new Exception('Error loading source file');
}
} catch (Exception $e) {
echo $e->getMessage();
}
Expected result:
----------------
Error loading source file
Error loading source file
Error loading source file
Actual result:
--------------
DOMDocument::load(): I/O warning : failed to load external entity
"not-a-file"
DOMDocument::load(): Start tag expected, '<' not found in map-not-xml.xml,
line: 1
DOMDocument::load(): Couldn't find end of Start Tag malformed line 2 in
map-malformed-xml.xml, line: 2
--
Edit bug report at https://bugs.php.net/bug.php?id=55184&edit=1
--
Try a snapshot (PHP 5.2): https://bugs.php.net/fix.php?id=55184&r=trysnapshot52
Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=55184&r=trysnapshot53
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=55184&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=55184&r=fixed
Fixed in SVN and need be documented: https://bugs.php.net/fix.php?id=55184&r=needdocs
Fixed in release: https://bugs.php.net/fix.php?id=55184&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=55184&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=55184&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=55184&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=55184&r=support
Expected behavior: https://bugs.php.net/fix.php?id=55184&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=55184&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=55184&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=55184&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=55184&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=55184&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=55184&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=55184&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=55184&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=55184&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=55184&r=mysqlcfg
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=55184&r=trysnapshot54