markscarts Posted September 26, 2012 Share Posted September 26, 2012 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%BD%EF%BF%BD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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 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). Quote Link to comment Share on other sites More sharing options...
markscarts Posted September 26, 2012 Author Share Posted September 26, 2012 Note, it appears IE will actually display the product image, but when viewing the source I find that IE merely nulls out the additional spaces or characters. Quote Link to comment Share on other sites More sharing options...
bsmither Posted September 27, 2012 Share Posted September 27, 2012 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. Quote Link to comment Share on other sites More sharing options...
bsmither Posted September 27, 2012 Share Posted September 27, 2012 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. Quote Link to comment Share on other sites More sharing options...
markscarts Posted September 27, 2012 Author Share Posted September 27, 2012 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. Quote Link to comment Share on other sites More sharing options...
Toucan Web Design Posted September 27, 2012 Share Posted September 27, 2012 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 Quote Link to comment Share on other sites More sharing options...
markscarts Posted September 27, 2012 Author Share Posted September 27, 2012 Thanks for the tip, I had the same thought. I really think it is a server setting and in googling I thought I saw a few rumors of probs with images in binary in db. Still no direct db access yet, but I will post here once I'm able to get to that and report how things turn out. Quote Link to comment Share on other sites More sharing options...
markscarts Posted September 28, 2012 Author Share Posted September 28, 2012 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 . . . Quote Link to comment Share on other sites More sharing options...
markscarts Posted September 28, 2012 Author Share Posted September 28, 2012 Seems there are issues with padding the field in binary, not supposed to be a problem with varbinary, but somethinmg like that seems to have been causing the prob . . . and for the record, utf8_unicode_ci was default for this database. See http://dev.mysql.com/doc/refman/5.0/en/binary-varbinary.html Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.