Simple Machines Community Forum

SMF Support => SMF 2.0.x Support => Topic started by: Rob Lightbody on October 11, 2024, 11:36:01 AM

Title: PHP 8.1 & 2.0.19 should be OK, but I'm getting an error
Post by: Rob Lightbody on October 11, 2024, 11:36:01 AM
If I understand correctly, the last version of PHP that 2.0.19 will support, is 8.1?

Using that, I get the following error (that I don't get on PHP 7.4).

8192: preg_replace_callback(): Passing null to parameter #3 ($subject) of type array|string is deprecated

Any advice appreciated please!

(Load.PHP attached - line 169)
Title: Re: PHP 8.1 & 2.0.19 should be OK, but I'm getting an error
Post by: vbgamer45 on October 11, 2024, 11:39:41 AM
It actually supports up to 8.0 php you will get some warnings on 8.1
Title: Re: PHP 8.1 & 2.0.19 should be OK, but I'm getting an error
Post by: Doug Heffernan on October 11, 2024, 11:42:29 AM
Also, do you have any custom mods installed? It might be that one of them isn't compatible with php 8.1.
Title: Re: PHP 8.1 & 2.0.19 should be OK, but I'm getting an error
Post by: Rob Lightbody on October 11, 2024, 11:51:00 AM
Quote from: Doug Heffernan on October 11, 2024, 11:42:29 AMAlso, do you have any custom mods installed? It might be that one of them isn't compatible with php 8.1.
Thanks - yes I do - how would I know which one might be the culprit?
Title: Re: PHP 8.1 & 2.0.19 should be OK, but I'm getting an error
Post by: Doug Heffernan on October 11, 2024, 11:53:17 AM
Quote from: Rob Lightbody on October 11, 2024, 11:51:00 AMThanks - yes I do - how would I know which one might be the culprit?

If their developer isn't active to answer support questions on their support topics, the best way to go about it imo is to uninstall them one by one and check after each uninstallation.
Title: Re: PHP 8.1 & 2.0.19 should be OK, but I'm getting an error
Post by: Rob Lightbody on October 11, 2024, 11:54:15 AM
Quote from: vbgamer45 on October 11, 2024, 11:39:41 AMIt actually supports up to 8.0 php you will get some warnings on 8.1

The funny thing is, if I set PHP to 8.0, the forum stops working altogether with the following error -
Fatal error: Uncaught Error: Call to undefined function mysql_connect() in /home/theqesto/public_html/forum/Sources/Subs-Db-mysql.php:70 Stack trace: #0 /home/theqesto/public_html/forum/Sources/Load.php(1994): smf_db_initiate() #1 /home/theqesto/public_html/forum/index.php(72): loadDatabase() #2 {main} thrown in /home/theqesto/public_html/forum/Sources/Subs-Db-mysql.php on line 70
But setting it to 8.1, 8.2 or 8.3 seems to work fine, except for the error noted in my first post which appears in the errors log.
Title: Re: PHP 8.1 & 2.0.19 should be OK, but I'm getting an error
Post by: vbgamer45 on October 11, 2024, 11:55:36 AM
Strange it shouldn't pickup the old mysql code should try the mysqli version. I would check that the 8.1 version has mysqli support built in.
Title: Re: PHP 8.1 & 2.0.19 should be OK, but I'm getting an error
Post by: vbgamer45 on October 11, 2024, 11:56:22 AM
I would post the full error message with file and line number for the original error as well.
I made a few tweaks on 2.0.19 to get it to work for 8.1 to remove those errors.
Title: Re: PHP 8.1 & 2.0.19 should be OK, but I'm getting an error
Post by: Doug Heffernan on October 11, 2024, 11:58:08 AM
Indeed. mysql_connect() has been deprecated since PHP 5.5.0.
Title: Re: PHP 8.1 & 2.0.19 should be OK, but I'm getting an error
Post by: Rob Lightbody on October 11, 2024, 12:10:09 PM
Quote from: vbgamer45 on October 11, 2024, 11:56:22 AMI would post the full error message with file and line number for the original error as well.
I made a few tweaks on 2.0.19 to get it to work for 8.1 to remove those errors.

Thanks - I've attached the load.php file to the original post as suggested.
Title: Re: PHP 8.1 & 2.0.19 should be OK, but I'm getting an error
Post by: vbgamer45 on October 11, 2024, 12:13:44 PM
I saw that but do you have the full error log message file and line number? or screenshot. Since the first post doesn't have detail. 8192 isn't a line in load.php
Title: Re: PHP 8.1 & 2.0.19 should be OK, but I'm getting an error
Post by: Rob Lightbody on October 11, 2024, 12:37:43 PM
Quote from: vbgamer45 on October 11, 2024, 12:13:44 PMI saw that but do you have the full error log message file and line number? or screenshot. Since the first post doesn't have detail. 8192 isn't a line in load.php

I've now added the line number (169)
not sure what you mean by the error log message file... !
Title: Re: PHP 8.1 & 2.0.19 should be OK, but I'm getting an error
Post by: vbgamer45 on October 11, 2024, 12:54:50 PM
Attached updated file.
Looks like your editor did some changes to the file since differs in coding style from the default smf 2.0.19 file.
Title: Re: PHP 8.1 & 2.0.19 should be OK, but I'm getting an error
Post by: Rob Lightbody on October 12, 2024, 11:12:55 AM
Quote from: vbgamer45 on October 11, 2024, 12:54:50 PMAttached updated file.
Looks like your editor did some changes to the file since differs in coding style from the default smf 2.0.19 file.

Thank you, that worked!  It seems that the editor thats built into cpanel's file manager is causing the problems.  I'll stick to Notepad++ from now on.
Title: Re: PHP 8.1 & 2.0.19 should be OK, but I'm getting an error
Post by: Doug Heffernan on October 12, 2024, 11:52:18 AM
Quote from: Rob Lightbody on October 12, 2024, 11:12:55 AMI'll stick to Notepad++ from now on.

A word of advice, if I may, whenever you are working on a file, no matter what editor you use, it's always best to make first a backup of said file beforehand. Notepad++ has a built in feature for that, called Auto Backup. It can be found at Settings->Preferences->Backup.

Like that, no matter what happens, you can always roll the file back to the state it was before it was changed.