Advertisement:

Author Topic: Re: What';s causing this subs.php error please?  (Read 311 times)

Offline smartmouse

  • Full Member
  • ***
  • Posts: 592
Re: What';s causing this subs.php error please?
« 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).

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

Online SpacePhoenix

  • Jr. Member
  • **
  • Posts: 162
Re: What';s causing this subs.php error please?
« Reply #1 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

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 72,310
Re: Re: What';s causing this subs.php error please?
« Reply #2 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?

Offline Aaron10

  • Full Member
  • ***
  • Posts: 528
  • Gender: Male
Re: Re: What';s causing this subs.php error please?
« Reply #3 on: May 17, 2020, 01:59:40 AM »
Yeah same issue here, it is indeed caused by prettyurls (every page)