News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

"File not found" when clicking on attachments

Started by spiros, December 07, 2024, 11:44:03 AM

Previous topic - Next topic

spiros

This is after upgrade from 2 to 2.1.

I can see the attachments in the attachments directory but when I click on any attachment I get "File not found."

For example, in this topic
https://www.nonsmokersclub.com/forum/index.php?topic=7141.0

In the error log I get:

Type of error
General
Error message
2: Array to string conversion
File
public_html/forum/Sources/Subs.php
Line
5137
URL of page causing the error
https://www.nonsmokersclub.com/forum/index.php?action=dlattach;topic=7141.0;attach=148
Backtrace information
#0: smf_error_handler()
Called from public_html/forum/Sources/Subs.php on line 5137
#1: getAttachmentFilename()
Called from public_html/forum/Sources/ShowAttachments.php on line 150
#2: showAttachment()
Called from public_html/forum/index.php on line 184


I ran the "Attachment integrity check" checked all options


The following errors were found during maintenance. Check the box next to the errors you wish to fix and hit continue.

 
Quote5 thumbnails are missing a parent attachment
 211 attachments/avatars have an entry but no longer exist on disk
 15 attachments no longer have a message associated with them
 4 avatars no longer have a member associated with them
 3 files do not have a corresponding entry in the database. (These will be deleted)

which resulted in deleting all attachments, hmmm, not much fixing. I do have a backup of the attachments folder though.

Doug Heffernan

Quote from: spiros on December 07, 2024, 11:44:03 AMI can see the attachments in the attachments directory but when I click on any attachment I get "File not found."

Try running the script attached to the following post and see if it would help.

https://www.simplemachines.org/community/index.php?topic=583745.msg4135957#msg4135957

shawnb61

Yes, the attachment integrity checker should be used with caution, especially during forum moves, copies, etc.  It runs from the assumption that you did some file maintenance, e.g., cleaning some folders, & you now want to delete references to those attachments.  It's very good at that.

A byproduct of this is that if you have a problem with your attachment folder configuration, it deletes all your attachments.

The 2.1 upgrader renames all attachments, by adding a .dat at the end.  Long story as to why, but it does.  So if you don't have the .dat there, either (a) the upgrader did not run to completion, or (b) the upgrader could not find the attachments.  The latter can happen if the attachment folder was moved prior to upgrade, and the corresponding settings were not made within SMF.

This can be a big problem for those who are moving forums while upgrading, e.g., to a new server.  Or building a test instance to test the upgrade.

Before running the upgrader, your configuration must be working perfectly.  Folders should be current, especially attachment, avatar, & custom avatar folders. 

The upgrader cannot operate on attachments & avatars it cannot find.  If the forum was moved, e.g., you're making a test copy, you MUST run repair_settings.php and fix all of the folders first.

If the ONLY problem you have is the lack of .dats, there are a couple options.  First, fix your attachment & avatar folders.  Once the folders are correct, you can rerun the upgrader with the 'rescan all attachments' option checked. 

There is also a script folks have around here that just renames the files.  I haven't used that.  It may be easier than rerunning the upgrader.
A question worth asking is born in experience & driven by necessity. - Fripp

spiros

Thank you so much, so I just reupload the attachments despite the fact that all attachments have been deleted by the "Attachment integrity check" (and I guess the pertinent dB entries too?) and run the script/rerun the upgrader?

shawnb61

The most important part to do first is to double & triple-check all your folder & url settings, especially for attachments, avatars, & custom avatars. 
A question worth asking is born in experience & driven by necessity. - Fripp

spiros

Yes, I have done that with repair_settings a number of times :)

Anyway, the .dat script did the job, but no attachments appear in the topics. Maybe the dB entries connecting those two deleted by the "Attachment integrity check"?

Kindred

Yes, that is what happened.  Suggest restoring the original database and rerunning the upgrade
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

spiros

Hmm, I have backed up the tables, delete the new attachments table and rename the old and then run upgrader?

Sir Osis of Liver

Yes, basically you should restore the 2.0 install so it's running currectly, check all paths, then rerun the 2.1 upgrade.
When in Emor, do as the Snamors.
                              - D. Lister

spiros

I mean can I just just revert to the 2.0 attachments table and run the upgrade on existing 2.1 version, i.e. not the whole 2.0 files and dB.

Sir Osis of Liver

No, because the links from posts to attachments were removed when you ran the integrity check.  You have to restore the 2.0 database, then rerun upgrade.php.  You don't need to restore the 2.0 files, but something caused the upgrade to fail, so it's a better idea to restore the 2.0 forum, make sure everything's ok, then run the upgrade.
When in Emor, do as the Snamors.
                              - D. Lister

Advertisement: