PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » Images » Image_Barcode » Bug #6637

error don't declare

Details

Submitted2006-01-31 11:37 UTC
Fromd dot shalygin at servplus dot ru
Assignedcweiske
StatusClosed
PackageImage_Barcode
PHP Version4.3.9
OSWindowsXP
Roadmaps(Not assigned)

Comments

[2006-01-31 11:37 UTC] d dot shalygin at servplus dot ru

Description:
------------
variable error don't declare on some scenary

Test script:
---------------
require_once("Image/Barcode/upca.php");
$str_to_print='029703006256';
$_barcode=new Image_Barcode_upca; $_barcode->_barcodeheight=50;
$_barcode->draw($str_to_print);
die;

Expected result:
----------------
<br />
<b>Notice</b>: Undefined variable: error in <b>c:\php\pear\Image\Barcode\upca.php</b> on line <b>197</b><br />
<br />
<b>Notice</b>: Undefined variable: error in <b>c:\php\pear\Image\Barcode\upca.php</b> on line <b>342</b><br />

Actual result:
--------------
before
if ( (is_numeric($text)==false) || (strlen($text)!=12) ) {
wright
$error=0;

[2006-10-12 14:41 UTC] chqs at sina dot com

function draw($text, $imgtype = 'png') {

if (!isset($error)) {
$error = isset($GLOBALS['error']) ? $GLOBALS['error'] : 0;
}

if ( (is_numeric($text)==false) || (strlen($text)!=12) ) {
$barcodewidth= (12 * 7 * $this->_barwidth) + 3 + 5 + 3 + 2 * (imagefontwidth($this->_font)+1);
$error = 1;
}

...

[2006-10-12 14:48 UTC] chqs at sina dot com

function draw($text, $imgtype = 'png') {

if ( (is_numeric($text)==false) || (strlen($text)!=12) ) {
$barcodewidth= (12 * 7 * $this->_barwidth) + 3 + 5 + 3 + 2 * (imagefontwidth($this->_font)+1);
$error = 1;
}
else {
// Calculate the barcode width
$barcodewidth = (strlen($text)) * (7 * $this->_barwidth)
+ 3 // left
+ 5 // center
+ 3 // right
+ imagefontwidth($this->_font)+1
+ imagefontwidth($this->_font)+1 // check digit's padding
;
$error = 0; // <-- Here, the bug is fixed
}

...