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

Bug #6024 Undefined variable: parameters
Submitted: 2005-11-21 08:29 UTC Modified: 2005-11-21 14:20 UTC
From: poweredbykrell at yahoo dot se Assigned: nosey
Status: Closed Package: Image_Graph
PHP Version: 4.3.11 OS: Linux 2.4.20 i686 GNU/Linux
Roadmaps: (Not assigned)    
Subscription  


 [2005-11-21 08:29 UTC] poweredbykrell at yahoo dot se
Description: ------------ Notice: Undefined variable: parameters in /www/pear/lib/Image/Graph/Common.php on line 248 Image_Graph 0.7.1 alpha Warning: Cannot modify header information - headers already sent by (output started at /www/pear/lib/Image/Graph/Common.php:248) in /www/pear/lib/Image/Canvas.php The foreach loop in the _error method appends data to an unassigned variable $parameters: foreach ($params as $name => $key) { if (isset($parameters)) { $parameters .= ' '; } $parameters .= $name . '=' . $key; <-------- } Test script: --------------- function _error($text, $params = false, $error_code = IMAGE_GRAPH_ERROR_GENERIC) { $i = 0; foreach ($params as $name => $key) { if ($i > 0) { $parameters .= ' '; } $parameters .= $name . '=' . $key; $i++; } $error =& PEAR::raiseError( $text . ($error_code != IMAGE_GRAPH_ERROR_GENERIC ? ' error:' . IMAGE_GRAPH_ERROR_GENERIC : '') . (isset($parameters) ? ' parameters:[' . $parameters . ']' : '') ); } Expected result: ---------------- It will work as supposed without an undefined variable notice Actual result: -------------- Notice: Undefined variable: parameters in /www/pear/lib/Image/Graph/Common.php on line 248

Comments

 [2005-11-21 08:40 UTC] poweredbykrell at yahoo dot se
This is a proposed fix function _error($text, $params = false, $error_code = IMAGE_GRAPH_ERROR_GENERIC) { foreach ($params as $name => $key) { if (isset($parameters)) { $parameters .= ' '; } else { $parameters = ''; } $parameters .= $name . '=' . $key; } $error =& PEAR::raiseError( $text . ($error_code != IMAGE_GRAPH_ERROR_GENERIC ? ' error:' . IMAGE_GRAPH_ERROR_GENERIC : '') . (isset($parameters) ? ' parameters:[' . $parameters . ']' : '') ); }
 [2005-11-21 14:20 UTC] nosey
This bug has been fixed in CVS. If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET). If this was a problem with the pear.php.net website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better.