• Welcome to Simple Machines Community Forum. Please login or sign up.

Bug in 2.0x? Errors in maintenance mode when dlattach action is hit

Started by dcmouser, December 29, 2019, 10:27:09 AM

Previous topic - Next topic

dcmouser

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();
proud member of donationcoder.com (forum)

m4z

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.
"Faith is what you have in things that don't exist."
--Homer Simpson

Es gibt hier im Forum ein deutsches Support-Board!
<werbung>Meine Freundin hat ihr erstes Buch veröffentlicht!</werbung>

shawnb61

Address the process rather than the outcome.  Then, the outcome becomes more likely.   - Fripp

Advertisement: