Jump to content

Broken Images - DB issue?


markscarts
 Share

Recommended Posts

I've been checking out a 4.4.7 install, slightly modded store, and there is some strange behavior I do not understand. It appears that when saving a product image to db, characters are added to end of product name into db field, thus ruining path and breaking images in store front.

Here is an example: http://www.love-bird...od&productId=13

On that page, NOTE the alt text that appears just above the image gallery, alt text for main product image is "Pay GBP20". If you right-click and view image info, you will see the issue.

You will see the image name is FUBARed:

http://www.love-birds-weddings.com/images/uploads/DSCN2116_344.JPG%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%B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%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD




I have checked the code for updating db field, and see no problem there:




$record['image'] = $db->mySQLSafe(imgPath($_POST['imageName'], false, ''));

Likewise, the imgPath() method seems fine. Any ideas?

CC: 4.4.7

PHP: 5.2.17

MySQL: 5.1.63-cll

BTW, I have replaced rte directory with one from 4.4.6 as suggested by C support in another thread. I have not yet checked the db directly (waiting for access just now).

Link to comment
Share on other sites

I have no answer, but my troubleshooting techniques involve the critical placement of a line of code that will write whatever I am interested in to a text file.

$dbgClue = "Clue or Variable";$dbg_nl = "rn";$dbgTrace = debug_backtrace();$dbgMsg = $dbgClue.$dbg_nl;foreach($dbgTrace as $dgb_index => $dbg_info) $dbgMsg .= "t at $dbg_index  ".basename($dbg_info['file'])." (line {$dbg_info['line']})->{$dbg_info['function']}(".join(',',$dbg_info['args']).")$dbg_nl"; $dbgMsg .= $dbg_nl; $dbg_fp = fopen(CC_ROOT_DIR.CC_DS.'dbg_trace_log.txt', 'a+');fwrite($dbg_fp, time().":".$dbgMsg."$dbg_nl-------------$dbg_nl");fclose($dbg_fp);

You will have to adjust CC_ROOT_DIR.CC_DS for whatever CC4 uses.

If I want to see what is actually getting sent to the database, I add this in the $db->insert() and $db->update() methods.

Link to comment
Share on other sites

The %EF%BF%BD sequence (three hex bytes) is what happens when a character that is not encoded as UTF-8 is being interpreted and rejected/replaced by application code as if it was supposed to be UTF-8 and is then redisplayed by a non-UTF-8-aware code.

So, I think somewhere along the way, and maybe being passed through myriad borders of UTF-8 -> non-UTF-8 interfaces, one tiny little error is getting magnified to the point of what you see.

If Devellion did switch up the database to be in a UTF-8 encoding state for the later versions of CC4, then maybe make sure the version of PHP running the store is also switched up to be in a UTF-8 encoding state. Or vice versa. Or versa vice.

Link to comment
Share on other sites

Thx I saw that about the three hex bytes while googling earlier, am interested in seeing the database table now but still haven't gotten access yet. I noticed that CC4 went to varbinary instead of varchar for the image names as opposed to CC3, also it seems CC3 specified collation of that field as latin1_swedish_ci and the field was not null. In CC4, no collation is specified when the field is created (some other inventory fields are specified as utf8_unicode_ci) and the field accepts null.

Not sure why those changes were made in CC4, but it'll probably be more important to see if the store owner's db has collation specified for the image field - or what the default collation is for his db.

I really appreciate your sharing the troubleshooting technique, I will try it in the meantime to see what's being sent.

Link to comment
Share on other sites

Not seen those particular characters, but I've seen similar garbage getting put at the end of images myself on some stores, couldn't track down the cause, but I think what I did find was that it only seemed to happen when the image field was being stored as binary or varbinary.

If bsmither's tactic doesn't work, could try switching it over to varchar, seemed to fix it in that particular case for me

Link to comment
Share on other sites

I still don't know what's caused the bug, MySQL version perhaps? It seems most stores are free of it, anyway changing the fieldtype to VARCHAR solved the issue, I removed extra spaces and/or characters from end of image names in db and after changing to varchar everything seems to work fine on updating.

BTW, when viewing image names in db, while problem was in force, an ellipses appeared after each image name, clicking the field would reveal that the entire allotment of 250 character spaces were filled . . .

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...