WebsiteBaker Logo
  • *
  • Templates
  • Help
  • Add-ons
  • Download
  • Home
*
Welcome, Guest. Please login or register.

Login with username, password and session length
 

News


WebsiteBaker 2.13.6 is now available!


Will it continue with WB? It goes on! | Geht es mit WB weiter? Es geht weiter!
https://forum.websitebaker.org/index.php/topic,32340.msg226702.html#msg226702


The forum email address board@websitebaker.org is working again
https://forum.websitebaker.org/index.php/topic,32358.0.html


R.I.P Dietmar (luisehahne) and thank you for all your valuable work for WB
https://forum.websitebaker.org/index.php/topic,32355.0.html


* Support WebsiteBaker

Your donations will help to:

  • Pay for our dedicated server
  • Pay for domain registration
  • and much more!

You can donate by clicking on the button below.


  • Home
  • Help
  • Search
  • Login
  • Register

  • WebsiteBaker Community Forum »
  • WebsiteBaker Support (2.8.x) »
  • Bakery Shop »
  • Bug: Image error in duplicating product
  • Print
Pages: [1]   Go Down

Author Topic: Bug: Image error in duplicating product  (Read 10561 times)

Offline Boudi

  • Posts: 1190
  • Gender: Male
  • //o_-\\
    • Yze Webdesign
Bug: Image error in duplicating product
« on: April 01, 2015, 03:18:28 PM »
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
Logged
...:: Bake the Unbakable ::...

freeSbee

  • Guest
Re: Bug: Image error in duplicating product
« Reply #1 on: April 01, 2015, 07:00:01 PM »
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:
Code: [Select]
// 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:
Code: [Select]
// 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
Logged

Offline Boudi

  • Posts: 1190
  • Gender: Male
  • //o_-\\
    • Yze Webdesign
Re: Bug: Image error in duplicating product
« Reply #2 on: April 01, 2015, 10:32:43 PM »
Allright, thnx  :-)

Test it out tomorrow :)
Logged
...:: Bake the Unbakable ::...

Offline Boudi

  • Posts: 1190
  • Gender: Male
  • //o_-\\
    • Yze Webdesign
Re: Bug: Image error in duplicating product
« Reply #3 on: April 02, 2015, 09:46:36 AM »
Update:

Bug has gone so happy. :-)

Good idea to implement this in an upgrade.

Again, thnx for your quick respond and solution.

Rgdz

Boudi

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

  • Print
Pages: [1]   Go Up
  • WebsiteBaker Community Forum »
  • WebsiteBaker Support (2.8.x) »
  • Bakery Shop »
  • Bug: Image error in duplicating product
 

  • SMF 2.0.19 | SMF © 2017, Simple Machines
  • XHTML
  • RSS
  • WAP2