News:

Looking for documentation? Take a look on our wiki

Main Menu

Bug in shop.browse

Started by doorknob, January 17, 2009, 13:58:38 PM

Previous topic - Next topic

doorknob

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
if( file_exists( VM_THEMEPATH . 'images/' . NO_IMAGE ) ) {

to
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.
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
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