Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 0.5.3

Bug #15229 Fatal error for files without XMP data
Submitted: 2008-12-03 21:35 UTC
From: toffee Assigned: boutell
Status: Closed Package: Image_JpegXmpReader (version 0.5.0)
PHP Version: 5.2.5 OS: Windows Vista
Roadmaps: (Not assigned)    
Subscription  


 [2008-12-03 21:35 UTC] toffee (Olivian Daniel Tofan)
Description: ------------ In case of files without XMP data the function readXmp returns null (line 109) instead of false and the test $this->readXmp() === false from getField method will fail. This will lead to call xpath (on line 365) on a null object. Test script: --------------- <?php require_once 'Image/JpegXmpReader.php'; $file = "test.jpg"; try { $xmpReader = new Image_JpegXmpReader($file); /* Will crash with: * "Call to a member function xpath() on a non-object" * if file does not contains XMP data; * (the string "http://ns.adobe.com/xap/1.0/" cannot be found) */ $xmpTitle = $xmpReader->getTitle(); } catch (Image_JpegMarkerReaderDamagedException $e) { echo("Not a valid file"); } ?> Expected result: ---------------- The function getTitle to return false if the file does not contains XMP data. Actual result: -------------- PHP Fatal error: Call to a member function xpath() on a non-object in C:\Program Files\PHP\PEAR\Image\JpegXmpReader.php on line 365

Comments

 [2008-12-06 12:57 UTC] doconnor (Daniel O'Connor)
 [2008-12-07 15:49 UTC] boutell (Thomas Boutell)
Thank you for your bug report. This issue has been fixed in the latest released version of the package, which you can download at http://pear.php.net/get/Image_JpegXmpReader Thanks, I have applied your patch and edited the documentation to clarify that the function should return false in this situation (as the rest of my code was already expecting...).