Simple Machines Community Forum

SMF Support => SMF 2.1.x Support => Topic started by: smartmouse on May 06, 2020, 09:09:54 AM

Title: Re: What';s causing this subs.php error please?
Post by: smartmouse on May 06, 2020, 09:09:54 AM
Hello, I have the same error in the forum logs:

"Invalid argument supplied for foreach()" on Sources/Subs.php (Line 3832).

3832: foreach (array_reverse($context['template_layers']) as $layer)
3833: loadSubTemplate($layer . '_below', true);
3834: }


My htaccess file is not empty. It is generated by PrettyUrls mod.

Currently I have 20,000 errors about that line in the logs panel.
How can I fix it?
Title: Re: What';s causing this subs.php error please?
Post by: SpacePhoenix on May 06, 2020, 03:43:11 PM
That means that the foreach was expecting to be given an array to work with but wasn't (probably either an interger or a string was received instead).

Whatever bit of code that is meant to build the $context['template_layers'] array, fails to do so. A quick fix for it would be to locate the code that is supposed to generate the $context['template_layers'] array and have it firstly create the $context['template_layers'] array as an empty array, that way the foreach will always be given an array to work with
Title: Re: Re: What';s causing this subs.php error please?
Post by: Arantor on May 08, 2020, 03:48:44 AM
Well, $context['template_layers'] in a normal setup is made automatically by SMF... that sounds like a mod is breaking it.

Is it every page or is it specific to certain pages?
Title: Re: Re: What';s causing this subs.php error please?
Post by: Aaron10 on May 17, 2020, 01:59:40 AM
Yeah same issue here, it is indeed caused by prettyurls (every page)