Author Topic: Error in modify.php  (Read 26667 times)

Offline scheltel

  • Posts: 48
Error in modify.php
« on: March 05, 2015, 03:28:42 PM »

When I try to save the settings of a payment provider in de logs the following error occurs:

[Thu Mar 05 14:02:45.367663 2015] [:error] [pid 18919] [client] PHP Notice:  Undefined index: main_image in /var/www/ on line 143, referer:

after replacing
Code: [Select]
<img src="<?php echo $main_thumb_url?>" alt="<?php echo $MOD_BAKERY['TXT_IMAGE']." "$post['main_image']; ?>" height="48" border="0" />
Code: [Select]
<img src="<?php echo $main_thumb_url?>" alt="<?php echo $MOD_BAKERY['TXT_IMAGE']." "$main_image?>" height="48" border="0" />
Is this change (replacing $post['main_image'] with $main_image OK?

Offline Gast

  • Posts: 5920
Re: Error in modify.php
« Reply #1 on: March 05, 2015, 03:46:27 PM »
whats your bakery version?

Offline scheltel

  • Posts: 48
Re: Error in modify.php
« Reply #2 on: March 05, 2015, 04:00:39 PM »
Version 1.7.1

Offline Gast

  • Posts: 5920
Re: Error in modify.php
« Reply #3 on: March 05, 2015, 04:15:41 PM »
okay, i see it, looks like Vers 1.71
P.S.: i read, it is Vers 1.7.1  ;-)

your question:
Is this change (replacing $post['main_image'] with $main_image OK?
simple answer: NO

$post is the answer of the select to the database about the main image and this answer must be an array.
the select search for the first picture to this ITEM_ID
the image table list all images, ordered by ITEM_ID and Item position, the Picture on position 1 is your main picture. if you dont change the picture position in the image administration on the product modify-Page, all images has position = 1, the select take's then the first picture as your main picture

$post['main_image'] is the filename of this first picture to this Item_ID without file extension like *.jpg
for example
complete filename = mypicturefile.jpg
$post['main_image'] = mypicturefile

$post['main_image'] is using as image title && image alt-text

now its possible, when you have some special chars or whitespaces or extra-points in your filename, the script cannot write this and leave the database field empty, but then, you have also no image to show

at first, go to WB-settings and there to advanced settings, search nearly in the top to php error reporting, switch that point to a setting with E_ALL, after that, the error message will show in the top of the WB-Backend, so you have not to read the logfile ever and ever
(Dont forget to switch back to E_NONE, when the problem is solved)

now test on other product pages - if WB shows the error, check the image filename, showing in the backend and the image filename in the folder media/bakery/images/your-Item_id

maybe (and hope) you found some problem with special chars etc.

P.S.: $main_image was a fix variable in Bakery Vers <= 1.60, this variable is not using in the same content in the newer bakery versions

if you use $main_image like your code example, the next error message come (maybe like array_merge())- because $main_image is a arrey now

hope, you understood my bad english

if you dont found any problem's in the picture names, change the code in line 143 // modify.php like this
Code: [Select]
<img src="<?php echo $main_thumb_url?>" alt="<?php echo $MOD_BAKERY['TXT_IMAGE'?>" height="48" border="0" />

« Last Edit: March 05, 2015, 04:23:16 PM by jacobi22 »