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 13:29 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 13: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 13: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 19:20 UTC] User who submitted this comment has not confirmed identity
If you submitted this note, check your email.If you do not have a message, click here to re-send
MANUAL CONFIRMATION IS NOT POSSIBLE.  Write a message to pear-dev@lists.php.net
to request the confirmation link.  All bugs/comments/patches associated with this

email address will be deleted within 48 hours if the account request is not confirmed!