Simple Machines Community Forum

SMF Support => SMF 2.0.x Support => Topic started by: spiros on January 02, 2018, 02:05:45 PM

Title: Has anyone tested PHP 7.2?
Post by: spiros on January 02, 2018, 02:05:45 PM
Has anyone tested PHP 7.2 on SMF?
Title: Re: Has anyone tested PHP 7.2?
Post by: Arantor on January 02, 2018, 02:16:33 PM
No. But I can tell you without any hesitation that it will start vomiting masses of deprecated errors everywhere.
Title: Re: Has anyone tested PHP 7.2?
Post by: Shambles on January 02, 2018, 05:15:13 PM
Quote from: Arantor
... I can tell you without any hesitation that it will start vomiting masses of deprecated errors everywhere.

You're not kidding.

QuoteFunction create_function() is deprecated
by the trillion.
Title: Re: Has anyone tested PHP 7.2?
Post by: Arantor on January 02, 2018, 05:17:07 PM
Yup, every single bbcode definition will cause errors. Probably multiple times per invocation of bbcode parser.

This was fixed in 2.1 but is borderline impossible to properly fix on 2.0 and every 2.0 bbcode.
Title: Re: Has anyone tested PHP 7.2?
Post by: Chen Zhen on January 02, 2018, 05:32:03 PM

You can suppress the deprecated warning for PHP 7.2 specifically.

add to function: error_handler()

// Disable PHP 7.2 "Function create_function() is deprecated"  errors from filling the forum error logs
if (defined('E_DEPRECATED') && $error_level == E_DEPRECATED && phpversion() == '7.2.0' && strpos($error_string, 'Function create_function() is deprecated') !== false)
return;


.. this will work fine for PHP 7.2 but the deprecated warning means in an upcoming version of PHP it will be removed altogether where this type of patch will not work.
Title: Re: Has anyone tested PHP 7.2?
Post by: vbgamer45 on January 02, 2018, 06:14:23 PM
I like that trick! I did that for SMF 1.1.x and still runs on php 7.1
Title: Re: Has anyone tested PHP 7.2?
Post by: Arantor on January 02, 2018, 06:50:17 PM
Quote from: Chen Zhen on January 02, 2018, 05:32:03 PM

You can suppress the deprecated warning for PHP 7.2 specifically.

add to function: error_handler()

// Disable PHP 7.2 "Function create_function() is deprecated"  errors from filling the forum error logs
if (defined('E_DEPRECATED') && $error_level == E_DEPRECATED && phpversion() == '7.2.0' && strpos($error_string, 'Function create_function() is deprecated') !== false)
return;


.. this will work fine for PHP 7.2 but the deprecated warning means in an upcoming version of PHP it will be removed altogether where this type of patch will not work.


You really shouldn't do a version comparison like that because when 7.2.1 comes out, it's not going to work... you could turn it into a version_compare() call instead and check for 7.2 or above all at once.

As for SMF 1.1 still working on PHP 7, writing a shim for the mysql_ functions, followed by replacing out all of the preg_replace with /e calls (which don't work in 7), along with all the other changes you're going to need to do, you might as well put the time in upgrading to 2.0 anyway because you're only going to spend more and more time patching up such issues.
Title: Re: Has anyone tested PHP 7.2?
Post by: vbgamer45 on January 02, 2018, 09:13:09 PM
I agree the comparison should be changed.. I am still waiting out for a few releases for 7.2 to come before i actually look to move to it for my non smf projects. For more SMF projects I most use SMF 2.0 except for legacy forum hosting where I still have many forums. waiting for 2.1 to make that big jump
Title: Re: Has anyone tested PHP 7.2?
Post by: spiros on May 16, 2018, 03:03:51 PM
Just tested with php 7.2.5, I see no errors on actual pages
https://www.translatum.gr/forum/index.php

on error log plenty of depreciated ones:

8192: Function create_function() is deprecated
/public_html/forum/Sources/Subs.php
Line: 1509
Title: Re: Has anyone tested PHP 7.2?
Post by: Kindred on May 16, 2018, 04:59:16 PM
Well, SMF 2.0.15 does not officially support 7.2
Title: Re: Has anyone tested PHP 7.2?
Post by: JasperC on March 16, 2019, 01:58:38 PM
My shared hosting service has forced me to use PHP 7.2 as of today, so I needed to suppress the deprecated warnings from the error logs as described above. I used Chen Zhen's solution with improved version comparing, so it looks like this:

// Disable PHP 7.2 "Function create_function() is deprecated"  errors from filling the forum error logs
if (defined('E_DEPRECATED') && $error_level == E_DEPRECATED && version_compare(phpversion(), '7.2', '>=') && strpos($error_string, ' create_function() is deprecated') !== false)
return;


However this did not seem to suppress all warnings, only about half of them. It seems that some are already generated before the error handler is set in index.php (I think particularly the reloadSettings() function is causing them, but I am not very familiar with the core functions of SMF). So I cut the following code from index.php...

// Register an error handler.
set_error_handler('error_handler');


...and pasted it a bit higher, right below this line:

require_once($sourcedir . '/Errors.php');

I thought this might be useful to anyone else having these issues. So far my forum seems to be running perfectly fine, hope it stays that way while I keep my eager eyes on the progress made on SMF 2.1 release candidates. :)

If anyone thinks this is a bad idea, please let me know.
Title: Re: Has anyone tested PHP 7.2?
Post by: spiros on March 16, 2019, 03:28:20 PM
I use this https://www.smfhacks.com/index.php?action=downloads;sa=view;id=215 and it is error-free even with 7.3

https://www.simplemachines.org/community/index.php?topic=564738.msg4010312#msg4010312