• Welcome to Simple Machines Community Forum. Please login or sign up.
November 26, 2021, 10:51:20 PM

News:

Check out the SMF Function DB!


Has anyone tested PHP 7.2?

Started by spiros, January 02, 2018, 02:05:45 PM

Previous topic - Next topic

spiros

Has anyone tested PHP 7.2 on SMF?

Arantor

No. But I can tell you without any hesitation that it will start vomiting masses of deprecated errors everywhere.
No good deed goes unpunished
All helpful urges should be circumvented

Shambles

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.

Arantor

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.
No good deed goes unpunished
All helpful urges should be circumvented

Chen Zhen


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.

My SMF Mods & Plug-Ins

WebDev


"Either you repeat the same conventional doctrines everybody is saying, or else you say something true, and it will sound like it's from Neptune." - Noam Chomsky

vbgamer45

I like that trick! I did that for SMF 1.1.x and still runs on php 7.1
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

Arantor

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.
No good deed goes unpunished
All helpful urges should be circumvented

vbgamer45

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
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

spiros

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

Kindred

Well, SMF 2.0.15 does not officially support 7.2
Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.<br /><br />"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

JasperC

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.


Advertisement: