Advertisement:

Author Topic: Bug in 2.0x? Errors in maintenance mode when dlattach action is hit  (Read 721 times)

Offline dcmouser

  • Charter Member
  • Jr. Member
  • *
  • Posts: 208
    • donationcoder.com
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:

Code: [Select]
// 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:

Code: [Select]
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)

Offline m4z

  • 98.8% chimp
  • Localizer
  • Sophist Member
  • *
  • Posts: 1,367
  • /mÉ›s/
Re: Bug in 2.0x? Errors in maintenance mode when dlattach action is hit
« Reply #1 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.
"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>

Offline shawnb61

  • Dev. Team Mentor
  • Developer
  • SMF Hero
  • *
  • Posts: 3,109
    • sbulen on GitHub
Re: Bug in 2.0x? Errors in maintenance mode when dlattach action is hit
« Reply #2 on: December 30, 2019, 02:47:16 PM »
Logged #110.

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