Simple Machines Community Forum

SMF Support => SMF 2.0.x Support => Topic started by: Arris on October 06, 2018, 11:48:37 AM

Title: PHP 7.2, create_function() and old mods code
Post by: Arris on October 06, 2018, 11:48:37 AM
http://php.net/manual/en/function.create-function.php

create_function — Create an anonymous (lambda-style) function

Warning
This function has been DEPRECATED as of PHP 7.2.0. Relying on this function is highly discouraged.

So, some mods uses create_function() in their install.xml or source code.

Is there any recommendations for migration to valid code?
Title: Re: PHP 7.2, create_function() and old mods code
Post by: d3vcho on October 06, 2018, 12:00:10 PM
PHP 7.2.x is not supported by SMF 2.0.x at this time.
Title: Re: PHP 7.2, create_function() and old mods code
Post by: Arantor on October 06, 2018, 12:29:13 PM
The only migration is to sit and rewrite every single bbcode mod (plus any others that used it).

All of the base ones in 2.1 are done but migrating this for 2.0 is borderline impossible to get right in a fixes-everything way.
Title: Re: PHP 7.2, create_function() and old mods code
Post by: Arris on October 06, 2018, 01:24:15 PM
Can I migrate from 2.0.15 to 2.1+ without problems?
Title: Re: PHP 7.2, create_function() and old mods code
Post by: Arantor on October 06, 2018, 01:27:34 PM
Well, 2.1 isn't ready yet. When it is, you will still need to get your theme updated (since 2.0 themes aren't compatible with 2.1), bbcode mods will definitely need updating, other mods may need updates too.

The fewer mods and changes you have, the better the upgrade possibility.
Title: Re: PHP 7.2, create_function() and old mods code
Post by: Ali_ on April 14, 2019, 01:46:38 PM
This causes my smf_log_errors table to grow incredibly fast.  It was bigger than the actual forum board/topics and now I have to create a stored proceedure and an event to truncate that table once every day.  Otherwise, mysql ends up filling memory with this nonsense.  I am worried about the hit it takes on IO.   The error log grew to 1GB in a couple of days.

Can I re-write the Subs.php file where the error seems to orgininate so that it doesn't use create_function(), but rather an anonymous function?  Has anyone done this?
Title: Re: PHP 7.2, create_function() and old mods code
Post by: vbgamer45 on April 14, 2019, 01:48:39 PM
Yes you can for default SMF mod at https://www.smfhacks.com/index.php?action=downloads;sa=view;id=215 that does most of it.
Title: Re: PHP 7.2, create_function() and old mods code
Post by: Kiriakos GR on April 15, 2019, 08:16:39 AM
Any one using cPanel for web site management,  he may use MultiPHP manager module and select PHP 5.6  as default PHP engine.

By using SMF2.0.X-enablePHP7.2Compat_v1.3,  this masked the problem but when tried to uninstall old mod which was still delivering errors,  my forum crashed ( white index ). 

I was had to restore files backup and database backup, then switched to PHP 5.6, and now I am back in the world of livings.
Old backup this deactivated SMF2.0.X-enablePHP7.2Compat_v1.3 and forum functionality this is now restored.

Error log clear, no issues at all.     
Title: Re: PHP 7.2, create_function() and old mods code
Post by: GigaWatt on April 15, 2019, 10:08:19 PM
You can always choose PHP 7.1, it's still supported (till the end of this year, I think ???).
Title: Re: PHP 7.2, create_function() and old mods code
Post by: Ali_ on April 19, 2019, 11:26:43 AM
@vbgamer45. Thank you, it worked like a charm.
Title: Re: PHP 7.2, create_function() and old mods code
Post by: iMiKK on September 22, 2019, 04:44:51 PM
Quote from: vbgamer45 on April 14, 2019, 01:48:39 PM
Yes you can for default SMF mod at https://www.smfhacks.com/index.php?action=downloads;sa=view;id=215 that does most of it.

Thank you very very much.