Missing attachments after OpenImporter import from SMF 2.0
March 07, 2015, 02:53:44 pm
I am missing attachments after using Openimporter. I have done some investigation and it seems missing attachments have different pattern of attachment filenames e.g.: Original filename = L-227-14.GIF Attachment filename = 8456_L-227-14_GIFb8f84b0c45c3a15688e133d1c42ebaec I believe these attachments date back to when the forum was SMF 1.0 or SMF 1.1. More recent attachments from SMF days are e.g. 84566_ac605dc8170a65c44d4ef597fb9ab090c0b49db0 I note that the second type of filename is purely lowercase alphanumeric and underscores whereas the first is upper and lower and includes hyphens. The length of filename is also variable as it includes the original filename. Is it possible that OpenImporter is failing due to filename issues?
Re: Missing attachments after OpenImporter import from SMF 2.0
Reply #2 – March 07, 2015, 05:28:28 pm
The files are missing in the Elk attachment folder but are present in the SMF attachment folder. I'll check what is in the database.
Re: Missing attachments after OpenImporter import from SMF 2.0
Reply #5 – March 07, 2015, 06:15:02 pm
So - the database misses a number of fields for the attachment - filehash and MIME type are blank. The thumbnail was regenerated since SMF 2.0 has has all missing fields populated - and successfully migrated. Therefore it probably is the missing filehash causing the import issue. The attachment works fine in SMF 2.0 despite the missing fields.
Re: Missing attachments after OpenImporter import from SMF 2.0
Reply #8 – March 08, 2015, 04:43:17 am
emanuele
Global Moderator
Okay, one last check. The name of the files in the attachments directory follow the scheme {id_attach}_randomstring. Can you check if there is a file whose name starts with the id of the L-227-14.GIF attachment?
Re: Missing attachments after OpenImporter import from SMF 2.0
Reply #9 – March 08, 2015, 04:57:39 am
Attachment 8456 in DB looks like this: id_attach|id_thumb|id_msg|id_member|attachment_type|filename|size|downloads|width|height|file_hash|fileext|mime_type|id_folder|approved 8456|446287|7666|0|0|L-227-14.GIF|53618|1995|800|398|[null]|gif|[null]|1|1 There are no files starting with 8456 except 8456_L-227-14_GIFb8f84b0c45c3a15688e133d1c42ebaec in SMF attachment folder. There are no files starting with 8456 in Elkarte attachment folder.
Re: Missing attachments after OpenImporter import from SMF 2.0
Reply #10 – March 08, 2015, 05:12:13 am
Looking through OpenImporter code I saw in SMF 1.1 importer code to fix the missing MIME type. if (empty($row['mime_type'])) { $fileext = ''; $mimetype = ''; $is_thumb = false; if (preg_match('/\.(jpg|jpeg|gif|png)(_thumb)?$/i',$row['filename'],$m)) { $fileext = strtolower($m[1]); $is_thumb = !empty($m[2]); if (empty($row['mime_type'])) { // AFAIK, all thumbnails got created as PNG if ($is_thumb) $mimetype = 'image/png'; elseif ($fileext == 'jpg') $mimetype = 'image/jpeg'; else $mimetype = 'image/'.$fileext; } This is not included in SMF 2.0 importer. SMF 2.0 importer does have code for missing filehash: if (empty($row['file_hash'])) { $row['file_hash'] = createAttachmentFileHash($row['filename']); $source_file = $row['filename']; This presumably does not generate "8456_L-227-14_GIFb8f84b0c45c3a15688e133d1c42ebaec" but "8456_b8f84b0c45c3a15688e133d1c42ebaec" which then cannot be copied as it doesn't exist.