SMF 2.0 - Maintenance Mode and Downloading Attachments

Started by GL700Wing, February 09, 2021, 05:55:02 AM

Previous topic - Next topic

GL700Wing

I successfully migrated and merged two forums for a business yesterday - this was the culmination of six months planning and preparation - and the client asked that the forum be left in Maintenance Mode until today.

Last night I noticed the error logs had lots of messages in them and they were all related to an attempt to access the forum using a link for downloading an attachment.  Unfortunately this sent me into a bit of a panic because, and despite all the testing I'd done, I thought I must have corrupted a source or theme file or, worse still, the database.

This concern was exacerbated by the fact that every time I visited the link, and in addition to 36 error messages being added to the log, I was presented with a 'white screen' login page instead of the standard Maintenance Mode login screen.  I spent hours trying to resolve this issue last night before I finally came across a message I posted about a similar issue almost four years ago.

The problem is caused by a bug is in ./index.php - basically the code to download an attachment does not check if the forum is in Maintenance Mode before it tries to detect the browser.

The current code code is:
if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'dlattach' && (!empty($modSettings['allow_guestAccess']) && $user_info['is_guest']))
I changed it to the following and now an attaempt to download an attachment while the forum is in maintenance mode redirects to the expected login screen:
if (empty($maintenance) && isset($_REQUEST['action']) && $_REQUEST['action'] == 'dlattach' && (!empty($modSettings['allow_guestAccess']) && $user_info['is_guest']))

Fortunately this issue has been addressed in SMF 2.1 RC3 - from ./index.php:
if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'dlattach' && empty($maintenance))
Life doesn't have to be perfect to be wonderful ...

Advertisement: