2010-04-29, 03:45 PM
Hello, all.
I know there is another thread on this topic, but it…uhm…devolved. I'm having the same issue, and looking through the code in the 1.4 Merge, I have hopefully a few insights.
What happens? The Uploads folder is empty; none of the attachments actually copied. Errors were only generated after the merge happened (i.e., the module can find my SMF attachments folder just fine, apparently). The DB entries for the attachments all look good, but the files themselves do not exist.
Errors generated: At the end of the merge, the generated report gives an error for each and every attachement in the SMF DB, that looks like this:
Interesting observation: There is no attachment with ID 1
Interesting observation 2: The attachment module never attempts to copy attachments with thumbnails (attachments with ID_THUMB != 0 in SMF DB). Perhaps the author misunderstood the role of ID_THUMB? It indicates that the attachment has a thumbnail, and that thumbnail is the attachment with ID_ATTACH equal to the value of ID_THUMB of the regular thumbnail. I notice that the module understands this differently and incorrectly: It presumes that if ID_THUMB !=0 then that attachment is a thumbnail (correct reading: It has a thumbnail). This is an error.
An example from my own SMF DB, I have the following two entries:
Fix:
in boards/smf/attachment.php change
Not so interesting observation 3: This error doesn't seem to be the cause of the missing attachment files. generate_raw_filename doesn't care whether it is looking at a thumbnail or not; nor does it need to care. But it must be failing somewhere to cause the "could not find the attachment" errors for each file. The only place I can figure that the generate_raw_filename function might be going wrong is in the MD5 bit. But a little testing on the filenames above shows that the function appears to be returning the correct results. So I'm a little mystified…UNLESS
Interesting observation 4:
Recall that I got an error for ATTACH_ID = 1. But there is no attachment in my SMF DB with ATTACH_ID = 1. Is this a off-by-one error, perhaps? So that generate_raw_filename is generating, for the attachment with filename KA-24-236_01_lg.jpg
So: I wonder: Are the SMF attachment importation errors a matter of mis-generating the filename based off an off-by-one error in the ID_ATTACH of the attachment?
(holy crap that was a long post! Sorry! But I do hope this is helpful?)
(this merge is being done on a local machine to test the import process for bugs, so I can't send a link; However, I'll gladly provide whatever else I can to help figure this one out.)
I know there is another thread on this topic, but it…uhm…devolved. I'm having the same issue, and looking through the code in the 1.4 Merge, I have hopefully a few insights.
What happens? The Uploads folder is empty; none of the attachments actually copied. Errors were only generated after the merge happened (i.e., the module can find my SMF attachments folder just fine, apparently). The DB entries for the attachments all look good, but the files themselves do not exist.
Errors generated: At the end of the merge, the generated report gives an error for each and every attachement in the SMF DB, that looks like this:
The following errors were logged during the process of the Merge System:
* Attachments:
o Error could not find the attachment thumbnail (ID: 1)
o Error could not find the attachment thumbnail (ID: 2)
o Error could not find the attachment (ID: 3)
o Error could not find the attachment thumbnail (ID: 4)
o Error could not find the attachment thumbnail (ID: 5)
o Error could not find the attachment (ID: 6)
o Error could not find the attachment thumbnail (ID: 7)
etc. I have quite a number of attachments, so I've truncated this list for convenience.Interesting observation: There is no attachment with ID 1
Interesting observation 2: The attachment module never attempts to copy attachments with thumbnails (attachments with ID_THUMB != 0 in SMF DB). Perhaps the author misunderstood the role of ID_THUMB? It indicates that the attachment has a thumbnail, and that thumbnail is the attachment with ID_ATTACH equal to the value of ID_THUMB of the regular thumbnail. I notice that the module understands this differently and incorrectly: It presumes that if ID_THUMB !=0 then that attachment is a thumbnail (correct reading: It has a thumbnail). This is an error.
An example from my own SMF DB, I have the following two entries:
ID_ATTACH ID_THUMB ID_MSG ID_MEMBER attachmentType filename
2 3 0 0 0 KA-24-236_01_lg.jpg
3 0 0 0 3 KA-24-236_01_lg.jpg_thumb
The first entry, ID_ATTACH=2, is a full attachment, whose thumbnail is the attachment wwith ID_ATTACH=3. The thumbnail, notice, has ID_THUMB=0 and attachmentType=3 (I do not know what attachmentTypes 1 or 2 are).Fix:
in boards/smf/attachment.php change
// Transfer attachment thumbnail
$thumb_not_exists = "";
if($data['ID_THUMB'] != 0)
to // Transfer attachment thumbnail
$thumb_not_exists = "";
if($data['ID_THUMB'] == 0)
Not so interesting observation 3: This error doesn't seem to be the cause of the missing attachment files. generate_raw_filename doesn't care whether it is looking at a thumbnail or not; nor does it need to care. But it must be failing somewhere to cause the "could not find the attachment" errors for each file. The only place I can figure that the generate_raw_filename function might be going wrong is in the MD5 bit. But a little testing on the filenames above shows that the function appears to be returning the correct results. So I'm a little mystified…UNLESS
Interesting observation 4:
Recall that I got an error for ATTACH_ID = 1. But there is no attachment in my SMF DB with ATTACH_ID = 1. Is this a off-by-one error, perhaps? So that generate_raw_filename is generating, for the attachment with filename KA-24-236_01_lg.jpg
1_KA-24-236_01_lg_jpgee3bcaecf39f06549b68a93163f99740
instead of the correct2_KA-24-236_01_lg_jpgee3bcaecf39f06549b68a93163f99740
I wonder? The module is just complex enough that I can't tell readily just browsing the code.So: I wonder: Are the SMF attachment importation errors a matter of mis-generating the filename based off an off-by-one error in the ID_ATTACH of the attachment?
(holy crap that was a long post! Sorry! But I do hope this is helpful?)
(this merge is being done on a local machine to test the import process for bugs, so I can't send a link; However, I'll gladly provide whatever else I can to help figure this one out.)