Login.english.php Undefined index: forum_name_html_safe

Started by GL700Wing, May 24, 2017, 09:43:58 PM

Previous topic - Next topic

GL700Wing

I have a test forum running SMF 2.0.14 and I've just noticed a series of error messages that start with "Undefined index: forum_name_html_safe in Login.english.php" and specifically relate to guests trying to view an avatar (./index.php?action=dlattach;attach=7292;type=avatar) but getting redirected to the login page because the forum is in Maintenance mode (if the forum is not in Maintenance mode the error message "You are not allowed to access this section" is displayed and no error messages are logged).

I've found that a similar problem was identified with SMF 2.1 in November 2015 (see Login.english.php Undefined index: forum_name_html_safe #3137) and the last comment in the issue log (from March 2016) suggests that a solution may have been found.

Just wondering if someone can provide details of the code edits required to fix this issue in SMF 2.0.14.

Life doesn't have to be perfect to be wonderful ...

Arantor


GL700Wing

Quote from: Arantor on May 25, 2017, 02:52:39 AM
https://github.com/SimpleMachines/SMF2.1/commit/7d41d5fbf3490380ffb7c5abb1da99de9c1f35c8 was the code change in 2.1 where this was fixed.
Thanks for the link - unfortunately I can't find the equivalent code in index.php in SMF 2.10.14.

However, I've been able to workaround the problem by commenting out the following 'else' statement in index.php - is this likely to cause other problems?.
    // 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();


The effect of commenting out the 'else' statement is that a standard login screen is always loaded instead of the strange looking screen in the attached image.

Life doesn't have to be perfect to be wonderful ...

Arantor

Um, loadTheme should always be called in a normal execution, it's just skipped for attachments because it isn't needed there.

Honestly though the way I solve this is to follow the performance guide for SMF and the first tip it has causes SMF to use a custom avatars folder which means the code you're getting at never has to run and your forum is significantly faster for little effort.

GL700Wing

Quote from: Arantor on May 25, 2017, 06:01:27 AM
Um, loadTheme should always be called in a normal execution, it's just skipped for attachments because it isn't needed there.

Honestly though the way I solve this is to follow the performance guide for SMF and the first tip it has causes SMF to use a custom avatars folder which means the code you're getting at never has to run and your forum is significantly faster for little effort.
I already have custom avatars folders configured for both the original and resized avatars (they are stored in separate folders outside of the main forum directory) so it seems this code is still being run - that said the issue only occurs when the forum is in Maintenance mode.
Life doesn't have to be perfect to be wonderful ...

Arantor

That doesn't make sense, because the URL you give is explicitly for custom avatars using the attachments folder...

GL700Wing

Quote from: Arantor on May 25, 2017, 06:34:39 AM
That doesn't make sense, because the URL you give is explicitly for custom avatars using the attachments folder...

This is the URL I'm currently using: https://fjcc.com.au/forum_fjcc/index.php?action=dlattach;attach=7805;type=avatar
Life doesn't have to be perfect to be wonderful ...

Arantor

Did you follow the instructions about using a custom avatar folder including the step to migrate all avatars to that folder? Because that might explain it.

GL700Wing

Quote from: Arantor on May 25, 2017, 06:55:38 AM
Did you follow the instructions about using a custom avatar folder including the step to migrate all avatars to that folder? Because that might explain it.
Yes - the URL I provided is a new avatar I just uploaded and it's definitely in the avatars folder that is not under the main forum directory.
Life doesn't have to be perfect to be wonderful ...

Illori

if that is the link you provided a few posts up, then no you did not follow the directions completely.

GL700Wing

Quote from: Illori on May 25, 2017, 07:27:45 AM
if that is the link you provided a few posts up, then no you did not follow the directions completely.

I did actually follow the directions completely but I manually edited the link I provided above to refer to the attachment number for an avatar I had just uploaded.

The original URL for which the problem occurred is https://fjcc.com.au/forum_fjcc/index.php?action=dlattach;attach=7292;type=avatar - I suspect the problem may be related to the fact that all the data in this forum was recently imported from vBulletin and the conversion script saved all the avatars as attachment files and not as avatar files.

Life doesn't have to be perfect to be wonderful ...

Arantor

And the guide I refer to includes a conversion step to convert them so literally none of them use index.php at all but point directly to the image to save multiple queries per avatar and of course, avoids all errors.

GL700Wing

Quote from: Arantor on May 25, 2017, 08:05:36 AM
And the guide I refer to includes a conversion step to convert them so literally none of them use index.php at all but point directly to the image to save multiple queries per avatar and of course, avoids all errors.
Apologies - I did run the command to access the hidden feature to move the avatars but I didn't realise the first command shown didn't actually do anything and that I needed to use the second command for SMF 2.0.14 (ie, the one that is listed as being for SMF 2.0 RC3).

However, and even after having done this, the error messages are still being generated.
Life doesn't have to be perfect to be wonderful ...

Advertisement: