Simple Machines Community Forum

SMF Development => Bug Reports => Topic started by: dcmouser on December 29, 2019, 10:27:09 AM

Title: Bug in 2.0x? Errors in maintenance mode when dlattach action is hit
Post by: dcmouser on December 29, 2019, 10:27:09 AM
I'm not sure what version this is appropriate for, but I just noticed a weird bug that I hadn't before.  In the root index.php is this code:

// Attachments don't require the entire theme to be loaded.
if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'dlattach' && (!empty($modSettings['allow_guestAccess']) && $user_info['is_guest']))
detectBrowser();
// Load the current theme.  (note that ?theme=1 will also work, may be used for guest theming.)
else
loadTheme();


What I was seeing is that when the server was in maintenance mode, I was getting a ton of errors in the log.

It turned out that the problem was that the dlattach request, which NORMALLY does not need theme and just serves an image to download, was, when maintenance mode was on and user was a guest, instead showing the user a "SITE UNDER MAINTENANCE" page.

But in that case, it was freaking out because the theme was not loaded.

Solution, just add a check on that line to check if they are going to need the theme since we are in maintenance mode:

if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'dlattach' && (!empty($modSettings['allow_guestAccess']) && $user_info['is_guest']) && (empty($maintenance) || allowedTo('admin_forum'))) {
detectBrowser();
}
// Load the current theme.  (note that ?theme=1 will also work, may be used for guest theming.)
else
loadTheme();
Title: Re: Bug in 2.0x? Errors in maintenance mode when dlattach action is hit
Post by: m4z on December 29, 2019, 11:01:44 AM
Thanks, we'll look into it. IIRC, the code around that case has been switched around a bit, so it might affect only 2.0.16.
Title: Re: Bug in 2.0x? Errors in maintenance mode when dlattach action is hit
Post by: shawnb61 on December 30, 2019, 02:47:16 PM
Logged #110.