Should missing file exceptions just return 404s?

Should missing file exceptions just return 404s?

by Chris Wharton -
Number of replies: 3

When I'm doing development with client code, and I don't have an up to date copy of their sitedata, I often run into missing file exceptions. Rsyncing 30GB+ isn't always practical. This can be quite annoying. Examples are editing course module settings when images in the description aren't present.

Of course it shouldn't happen on actual production site because playing with sitedata is bad! I can get around the error by hacking the filelib temporarily.


I'd like peoples opinions:

Should this be a fatal exception?

Or should filelib just return a 404 for missing files?

Can not read file, either file does not exist or there are permission problems

More information about this error
Debug info: [dataroot]/filedir/96/65/96656d3179a228823322761c3de1dad9b0a5a338
Error code: storedfilecannotread
Stack trace:

    line 187 of /lib/filestorage/stored_file.php: file_exception thrown
    line 881 of /lib/filestorage/stored_file.php: call to stored_file->update()
    line 424 of /lib/filelib.php: call to stored_file->set_source()
    line 178 of /course/modedit.php: call to file_prepare_draft_area()
Average of ratings: -
In reply to Chris Wharton

Re: Should missing file exceptions just return 404s?

by Richard Oelmann -
Picture of Core developers Picture of Plugin developers Picture of Testers

Surely if you are working on a clone of the client's site, if you clone the database and the dataroot at the same time, that shouldn't happen (put it into maintenance mode before you make the clone so its not changing).

If you clone the site code and the database, but not the data folder itself (or use an out of date copy of the data folder), then this issue is almost inevitable.


In reply to Richard Oelmann

Re: Should missing file exceptions just return 404s?

by Chris Wharton -

Yes, it is inevitable in the case of missing sitedata.

But does it seem right that a web page breaks completely if a non essential file is missing, rather than just returning a 404 and showing a missing file icon in the page?

In reply to Chris Wharton

Re: Should missing file exceptions just return 404s?

by Richard Oelmann -
Picture of Core developers Picture of Plugin developers Picture of Testers

Personally, I'd say the error message coming up provides far more information than a simple 404 page and may be important if the same error cropped up for someone with their site set up correctly, so taking that information away and providing just a 404 error page could lead to people who do have the correct sitedata folder (or at least, aim to have) not getting debug information to help solve an issue.


Out of interest, what shows for a 'normal user' without debugging enabled? - I would say there is potentially a case to have some kind of 404 page without the debug stack trace for users who do not have debugging enabled, if the alternative is a plain white screen crash as sometimes happens with these 'fatal errors'

For developers, I'd say the debug info is the right way to go, and not a simple 404 page.

Average of ratings: Useful (1)