PEAR is discontinued

This is a static archive preserving historical releases and metadata. No new packages or updates will be published. For updates to existing packages, or to publish new packages, please use Composer and Packagist.

Home » Images » Image_Tools » Bug #8840

Undefined local variable resultImage

Details

Submitted2006-10-03 14:00 UTC
Fromrumata at php dot net
Assignedfirman
StatusClosed
PackageImage_Tools
PHP VersionIrrelevant
OSirrelevant
Roadmaps(Not assigned)

Comments

[2006-10-03 14:00 UTC] rumata at php dot net

Description:
------------
Illegal usage of the local variable $resultImage in 'Image_Tools::display' and 'Image_Tools::save' methods
at Image/Tools.php

When using Image::Tools package with any mistakes (for example: passing filename of non-existent image)

Actual lines are
657: return PEAR::raiseError('Error rendering: ' . $resultImage->getMessage());
705: return PEAR::raiseError('Error rendering: ' . $resultImage->getMessage());

IMHO, they must be
657: return PEAR::raiseError('Error rendering: ' . $res->getMessage());
705: return PEAR::raiseError('Error rendering: ' . $res->getMessage());

Test script:
---------------
<?php

// Modified example from the package
require_once 'Image/Tools.php';
$options = array('image' => 'non-existent-path/pear.png');

$tool =& Image_Tools::factory('swap', $options);
if (PEAR::isError($tool)) { die($tool->toString()); }

$err = $tool->display();
if (PEAR::isError($err)) { die($err->toString()); }

?>

Expected result:
----------------
[pear_error: message="Error rendering: Failed to create image from string data" code=0 mode=return level=notice prefix="" info=""]

Actual result:
--------------
Warning: imagecreatefromstring() [function.imagecreatefromstring]: Data is not in a recognized format. in z:\home\localhost\www\Image\Tools.php on line 542

Notice: Undefined variable: resultImage in z:\home\localhost\www\Image\Tools.php on line 657

Fatal error: Call to a member function getMessage() on a z:\home\localhost\www\Image\Tools.php on line 657