Author Topic: Bug in shop.browse  (Read 2693 times)

doorknob

  • Jr. Member
  • **
  • Posts: 151
Bug in shop.browse
« on: January 17, 2009, 13:58:38 pm »
When the NO_IMAGE constant is an empty string, shop.browse crashes at line 357.
This is caused because the validation check in the previous line only returns a false value if NO_IMAGE has a non-empty value and the file can't be found. If the valu is empty, file_exists() returns true because the directory where the file should be located does exist, even though no file is specified. I fixed this by changing line 356 from
Code: [Select]
if( file_exists( VM_THEMEPATH . 'images/' . NO_IMAGE ) ) {
to
Code: [Select]
if( file_exists( VM_THEMEPATH . 'images/' . NO_IMAGE ) && NO_IMAGE != '' ) {

similarly, the block of code at lines 364 to 378 needs a test that $product_full_image is populated, i.e.
Code: [Select]
if( substr( $product_full_image, 0, 4) != 'http' ) {
// This is a local image
if( file_exists( IMAGEPATH . 'product/' . $product_full_image ) ) {
$full_image_info = getimagesize( IMAGEPATH . 'product/' . $product_full_image );
$full_image_width = $full_image_info[0]+40;
$full_image_height = $full_image_info[1]+40;
}

$product_full_image = IMAGEURL . 'product/' . $product_full_image;
} elseif( !isset( $full_image_width ) || !isset( $full_image_height ) ) {
// This is a URL image
$full_image_info = getimagesize( $product_full_image );
$full_image_width = $full_image_info[0]+40;
$full_image_height = $full_image_info[1]+40;
}
changed to
Code: [Select]
if( $product_full_image ) {
if( substr( $product_full_image, 0, 4) != 'http' ) {
// This is a local image
if( file_exists( IMAGEPATH . 'product/' . $product_full_image ) ) {
$full_image_info = getimagesize( IMAGEPATH . 'product/' . $product_full_image );
$full_image_width = $full_image_info[0]+40;
$full_image_height = $full_image_info[1]+40;
}

$product_full_image = IMAGEURL . 'product/' . $product_full_image;
} elseif( !isset( $full_image_width ) || !isset( $full_image_height )) {
// This is a URL image
$full_image_info = getimagesize( $product_full_image );
$full_image_width = $full_image_info[0]+40;
$full_image_height = $full_image_info[1]+40;
}
}

Tested on
J1.5.9 with vm from svn build 17/1/09

Phil