SMF 2.0.15 + PHP 7.1 - [] operator not supported for strings

Started by PhilGer, October 27, 2018, 05:00:20 PM

Previous topic - Next topic

PhilGer

Hi!
I'm currently running SMF 2.0.15 with PHP 7.0. – Everything is fine.

However, my web hosting provider will discontinue support for PHP 7.0 soon and so I need to move to PHP 7.1 (preferably even PHP 7.2.) – I tested my forum with PHP 7.1 (and 7.2) and encountered a major problem.

In most boards I see the error message ...
    [] operator not supported for strings
...whenever a topic should be displayed. (.../forum/index.php?topic=12345.0).

  • This error does not happen for guest sessions without log-in.
  • I uninstalled all mods, but that did not make a difference.
  • I searched for this error message here in forum and found a couple of threads about it, but none seems to match my situation.

Has anyone a idea how to solve this issue? - Thank you!

Arantor

Do you get any more information about the error, like which file it was in or where in the file?

I know older versions of TinyPortal had this bug for sure, but I don't recall seeing it lately in 2.0.15...

vbgamer45

Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

Kindred

Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

PhilGer

Quote from: Arantor on October 27, 2018, 05:14:35 PM
Do you get any more information about the error, like which file it was in or where in the file?
Unfortunately the error message is only displayed right in the page instead of the topic. There is no additional information there beyond the plain message "[] operator not supported for strings".
The error is not logged in the SMF error logs at all!
The forum is on shared hosting and I do not have access to any server log files.

Quote from: Kindred on October 27, 2018, 10:11:24 PMSmf does not currently support php 7.2
Well, fair enough. Let's leave PHP 7.2 for another time.
The crucial point right now is the issue happening with PHP 7.1 and me being forced to upgrade to 7.1 soon.

Arantor


PhilGer

I attached a screenshot of the error message. - I blurred out some areas; hope that does not interfere with diagnosis.


There is just one more thing I failed to notice before.
The error itself does not show up in the SMF error log but whenever the error is triggered, there are three errors added to the log.

http://www.not-the-real-domain.de/forum/index.php?topic=23597.0
2: Invalid argument supplied for foreach()
File: /is/htdocs/contractid/www/forum/Themes/default/Errors.template.php (body_above sub template - eval?) Line: 386

http://www.not-the-real-domain.de/forum/index.php?topic=23597.0
8: Undefined index: menu_buttons
File: /is/htdocs/contractid/www/forum/Themes/default/Errors.template.php (body_above sub template - eval?) Line: 386

http://www.not-the-real-domain.de/forum/index.php?topic=23597.0
8: Undefined index: show_pm_popup
File: /is/htdocs/contractid/www/forum/Themes/default/Errors.template.php (html_above sub template - eval?)  Line: 112 


Arantor


PhilGer

I attached the file (appended .txt file extension).
I looks like the file was manually customized by the previous owner of the forum. I was not aware of that until now.


PhilGer

Quote from: Sh@mbles on October 28, 2018, 09:44:42 AM
Possibly related (board-wise) ?

https://www.simplemachines.org/community/index.php?topic=554454
I looked at that topic before posting.
On the PHP-Programming level it is most likely the same code construct that causes the issue I'm dealing with. Beyond that, I don't think these issues are related. The very issue described in that topic is defintely fixed in SMF 2.0.15; I double checked the offending code line in my installation.

Arantor

OK, so it's not actually related but it does tell me something useful: the errors are caused because things are failing before it gets to the theme (so things the theme expected to have set up already aren't)

If it's happening only in topics... please attach Sources/Display.php next. I have an idea where it might be.

PhilGer

Quote from: Arantor on October 28, 2018, 10:26:16 AMIf it's happening only in topics... please attach Sources/Display.php next. I have an idea where it might be.
I have not seen it happening anywhere else, yet.

Display.php is attached....

Arantor

OK, so that's weird. Display.php matches an unmodified 2.0.15 file, and I can't reproduce the thing I expected to break on a 7.1 installation.

Are you sure all the other mods are uninstalled?

PhilGer

Quote from: Arantor on October 28, 2018, 11:20:49 AMAre you sure all the other mods are uninstalled?
Well, I think so. If I understand correctly, all the packages listed in the screenshot are available locally, but not installed.
(Say Thanks 1.3.6 was installed only after I detected the issue at hand.)



Arantor

Hrm, very strange. If you temporarily use the default theme, does it still happen on topics?

I'm just trying to isolate where the problem might be - though it might be worth asking your host if they have more detailed error logs. If not I have one idea that might help with that but solely as a temporary measure...

PhilGer

Quote from: Arantor on October 28, 2018, 11:56:35 AMHrm, very strange. If you temporarily use the default theme, does it still happen on topics?
We were thinking in the same direction.
I did a full diff of my SMF files vs. the clean 2.0.15 installation. No difference, except for settings.php. - But I have a lot of additional files, particularly in \Themes.
So, I cycled through all installed themes (SMF Default - Curve, Core Theme, Whitebox and NightBreeze 2). - The error is still there with each of the themes!

Quote from: Arantor on October 28, 2018, 11:56:35 AMI'm just trying to isolate where the problem might be - though it might be worth asking your host if they have more detailed error logs. If not I have one idea that might help with that but solely as a temporary measure...
No luck with the host. They upgraded all their shared customers from PHP 5 to 7 this week and had to turn off PHP logs altogether because the volume of errors in the log was becoming a problem.

So, I'm open for any idea to pinpoint the cause of this issue.

Arantor

OK, so this won't be pretty... if you edit Settings.php and before the closing ?> in it, add:

$db_show_debug = true;

This will turn off SMF's normal error handling and when the error hits, it should indicate where it is directly.

PhilGer

Not pretty? - You're so wrong. It's looking absolutely fabulous!


Notice: Undefined index: menu_buttons in /is/htdocs/contractid/www/forum/Themes/default/Errors.template.php (body_above sub template - eval?) on line 386
Warning: Invalid argument supplied for foreach() in /is/htdocs/contractid/www/forum/Themes/default/Errors.template.php (body_above sub template - eval?) on line 386

Error: [] operator not supported for strings in /is/htdocs/contractid/www/forum/Sources/Subs-SimTopics.php:147
Stack trace:
#0 /is/htdocs/contractid/www/forum/Sources/Subs-SimTopics.php(24): simtopics_check()
#1 /is/htdocs/contractid/www/forum/Sources/Subs.php(4227): simtopics_menu_buttons(Array)
#2 /is/htdocs/contractid/www/forum/Sources/Subs.php(4112): call_integration_hook('integrate_menu_...', Array)
#3 /is/htdocs/contractid/www/forum/Sources/Subs.php(3302): setupMenuContext()
#4 /is/htdocs/contractid/www/forum/Sources/Subs.php(3374): setupThemeContext()
#5 /is/htdocs/contractid/www/forum/Sources/Subs.php(2834): template_header()
#6 /is/htdocs/contractid/www/forum/index.php(173): obExit(NULL, true, true)
#7 {main}

Templates:4: index (whitebox_202), SayThanks (default), Display (default), Errors (default).
Sub templates:8: init, html_above, body_above, saythanks_above, fatal_error, saythanks_below, body_below, html_below.
Sprachdateien:4: index+Modifications.english (whitebox_202), index+Modifications.german (whitebox_202), SimTopics.english (whitebox_202), SimTopics.german (whitebox_202).
Stylesheets:1: saythanks (default).
inkludierte Dateien:11 - 537KB. (zeige)
Abfragen verwendet: 19


So, it looks like the Similar Topics Mod is still active although it is listed as not active. - And yes, thinking about it, I've seen the list of similar topics recently despite the mod being (supposed to be) uninstalled.

Arantor

Hmm, so that implies that it uses integration hooks to do its thing rather than file edits - I don't remember if anyone built a tool to clear out the integration hooks or not, off hand.

Failing that, if you wanted to attach that file here I can fix it for you.

PhilGer

Quote from: Arantor on October 28, 2018, 03:44:23 PM
Hmm, so that implies that it uses integration hooks to do its thing rather than file edits - I don't remember if anyone built a tool to clear out the integration hooks or not, off hand.

Failing that, if you wanted to attach that file here I can fix it for you.
I fixed it already. I changed Sources\Subs-SimTopics.php, line 69 from:
$context['similar_topics'] = '';
to:
$context['similar_topics'] = array();
The error seems to be gone!

Thank you very much! Fixing this was easy, but your help localizing the source of the problem is invaluable!

My bedtime reading today will be about Integration Hooks.

Arantor

That would certainly do it and is the kind of thing that PHP 7.1 makes devs fix now, glad you got it sorted :)

Illori

Quote from: Arantor on October 28, 2018, 03:44:23 PM
Hmm, so that implies that it uses integration hooks to do its thing rather than file edits - I don't remember if anyone built a tool to clear out the integration hooks or not, off hand.

both repair_settings.php and fix_packages.php can clear out all hooks.

vbgamer45

If Subs-SimTopics.php is from a mod contact the mod author to update it as well.
Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

PhilGer

Sorry for the late reply. I had no time for admin tasks during the week.
Quote from: vbgamer45 on October 28, 2018, 04:40:21 PM
If Subs-SimTopics.php is from a mod contact the mod author to update it as well.
I installed the most recent version (0.8.1) of Similar Topics today and the problem is fixed there already.

The whole hassle with the error message was only because the old version (0.6) of Similar Topics, containing the error, appeared to be uninstalled but was still active anyway.

Thanks to everybody who participated in this thread!

Advertisement: