Bug: Image error in duplicating product

Boudi

Update:

Bug has gone so happy. :-)

Good idea to implement this in an upgrade.

Again, thnx for your quick respond and solution.

Rgdz

Boudi

...:: Bake the Unbakable ::...

Boudi

...:: Bake the Unbakable ::...

freeSbee

Hi Boudi

Thanks for your bug report and the accurate description of what you have done. It helped me a lot to locate the bug.

Quick fix. Search the file save_item.php (about line 297) for:

// Delete image if requested
foreach ($images as $image) {
if ($image['delete_image'] !== false) {
$img_file = $image['delete_image'];
// Thumbs use .jpg extension only
$thumb_file = str_replace (".png", ".jpg", $img_file);
// Try unlinking image and thumb
if (file_exists(WB_PATH.MEDIA_DIRECTORY.'/bakery/images/item'.$item_id.'/'.$img_file)) {
unlink(WB_PATH.MEDIA_DIRECTORY.'/bakery/images/item'.$item_id.'/'.$img_file);
}
if (file_exists(WB_PATH.MEDIA_DIRECTORY.'/bakery/thumbs/item'.$item_id.'/'.$thumb_file)) {
unlink(WB_PATH.MEDIA_DIRECTORY.'/bakery/thumbs/item'.$item_id.'/'.$thumb_file);
}
// Delete image in database
$database->query("DELETE FROM ".TABLE_PREFIX."mod_bakery_images WHERE `filename` = '$img_file'");
// Check if there was a db error
if ($database->is_error()) {
$errors[] = $database->get_error();
}
}
}


Replace by:

// Delete image if requested
foreach ($images as $img_id  => $image) {
if ($image['delete_image'] !== false) {
$img_file = $image['delete_image'];
// Thumbs use .jpg extension only
$thumb_file = str_replace (".png", ".jpg", $img_file);
// Try unlinking image and thumb
if (file_exists(WB_PATH.MEDIA_DIRECTORY.'/bakery/images/item'.$item_id.'/'.$img_file)) {
unlink(WB_PATH.MEDIA_DIRECTORY.'/bakery/images/item'.$item_id.'/'.$img_file);
}
if (file_exists(WB_PATH.MEDIA_DIRECTORY.'/bakery/thumbs/item'.$item_id.'/'.$thumb_file)) {
unlink(WB_PATH.MEDIA_DIRECTORY.'/bakery/thumbs/item'.$item_id.'/'.$thumb_file);
}
// Delete image in database
$database->query("DELETE FROM ".TABLE_PREFIX."mod_bakery_images WHERE `img_id` = '$img_id'");
// Check if there was a db error
if ($database->is_error()) {
$errors[] = $database->get_error();
}
}
}



Regards Christoph

Boudi

Hi,

Noticed an annoying bug in Bakery 1.71:

Create a product and upload image
Click SAVE
DUPLICATE product
Click SAVE
Change title
Set Online view to ON
Check box to delete image and search/fill the new image to upload
Click SAVE

Bug: the image from the previous product is gone. Both in backend/frontend. Re-upload the image is not possible because the image itself is still in the Media dir.

So the only workaround for now is delete all the Media ID files, reupload the pictures and do NOT duplicate products but create them one by one.

Tested on 2 different setups on different servers.

Boudi
...:: Bake the Unbakable ::...