Simple Machines Community Forum

SMF Support => SMF 2.0.x Support => Topic started by: bongobongo on March 28, 2018, 08:48:23 AM

Title: create_function in Sources/Subs.php - errors in log_errors table - PHP 7.2.0
Post by: bongobongo on March 28, 2018, 08:48:23 AM
I'm helping someone with a SMF forum which currently is running on a server which newly moved to PHP 7.2.0
She has probably gotten a notice about the move to PHP 7.2.0, but since she had no experience with PHP versions etc. she did not understand that the PHP upgrade could cause conflict with SMF version 2.0.15.

After I upgraded the previous SMF 1.1 to SMF 2.0.15 (this was before I new the current host was using PHP 7.2.0) all looked quite nice.
But then i noticed in PhpMyAdmin that the log_errors table was huge. When I looked at some of the records there I see that the cause for all these error records are because Sources/Subs.php file use the PHP "create_function".

I know that 2.0.15 is not supposed to be working against PHP 7.2.0,
but since we have not yet found any other PHP 7.2.0 related issues (yet), and because we will move the SMF forum and domain to another host after easter, I would like to ask someone here if anybody has looked into how one could change current Sources/Subs.php file for the SMF 2.0.15, so it works against PHP 7.2.0, and so it no longer uses the PHP create_function ?

Title: Re: create_function in Sources/Subs.php - errors in log_errors table - PHP 7.2.0
Post by: Kindred on March 28, 2018, 10:40:36 AM
Since SMF does not support 7.2 - no...    no effort has been made to look into that yet.
Title: Re: create_function in Sources/Subs.php - errors in log_errors table - PHP 7.2.0
Post by: bongobongo on March 28, 2018, 12:48:36 PM
Just a short note:
I now that current version of SMF does not support PHP 7.
But the people which offer the web hotel has said that from december this year, they will only support PHP 7.

If SMF is not going to support PHP 7 in near future, I suspect there will be a lot of disappointed SMF users in a not to distant future.

From what I can see, there is no errors generated from other parts of SMF (have not tested it all though), than from the Sources/Subs.php file and where it is the php create_function which cause the problem.
After looking at the code generating the errors, it looks like there is not a huge job to make the needed changes to make it work in PHP 7.
But since I'm not a SMF expert I might be wrong in my assumptions.

Anyway... a lot of companies offering web hotel, will probably do the same as Sircon company - in near future.

Is there any time schedule for when SMF will support PHP 7?

Which file is handling the error logging?
I could for now change that file, and just skip errors generated by the create_function.
This way the error table will not be flooded with error records.
Title: Re: create_function in Sources/Subs.php - errors in log_errors table - PHP 7.2.0
Post by: Antes on March 28, 2018, 12:50:42 PM
SMF is supporting php7 & php7.1, thing is php7.2 deprecated/removed create_function which requires massive work. You can do a project search on SMF files and see for yourself.
Title: Re: create_function in Sources/Subs.php - errors in log_errors table - PHP 7.2.0
Post by: Kindred on March 28, 2018, 01:14:15 PM
Exactly... SMF supports php7, just not 7.2
Title: Re: create_function in Sources/Subs.php - errors in log_errors table - PHP 7.2.0
Post by: bongobongo on March 28, 2018, 03:52:10 PM
We just decided that we skip the error logging caused by the create_function.
NOTE! This is not a "solution"/hack I would recommend others to use, unless they have carefully considered other options.

But if other need this "fix" - here it is:

To disable this kind of error logging i changed this file:
Sources/Errors.php

just after the global definition inside the log_error function I added this piece of code:

Code: [Select]
if (strpos($error_message, 'create_function') !== false) {
return $error_message;
}

If I had not done the modification above, then each pageload on the frontend would result in 28 new records in the _log_errors table.

Title: Re: create_function in Sources/Subs.php - errors in log_errors table - PHP 7.2.0
Post by: Chen Zhen on March 28, 2018, 04:43:14 PM

That will not stop the actual PHP error log from filling up plus there is more than just instances of create_function that cause errors.
You can install the following plug-in that will fix some of the code:
https://web-develop.ca/index.php?action=downloads;area=stable_smf_modifications;file=48

If you use it please report any other deprecated code you come across so I can add it.
It alters all the create_functions to anonymous and changes some other code due to newer syntax.
 
 
Title: Re: create_function in Sources/Subs.php - errors in log_errors table - PHP 7.2.0
Post by: vbgamer45 on March 28, 2018, 04:46:41 PM
Chen I would recommend that patch to the SMF team looks very good!
Title: Re: create_function in Sources/Subs.php - errors in log_errors table - PHP 7.2.0
Post by: bongobongo on March 28, 2018, 04:50:28 PM
Hi Chen Zhen:
You wrote among other things this:

"...That will not stop the actual PHP error log from filling up plus there is more than just instances of create_function that cause errors..."

Well, that code snippet I posted in my previous post in this thread stopped all errors caused by the create_function not to be logged. I have tested it, and it works. But as I said it is a "hack", and I do not encourage others to use that "hack" unless they really really need it, and understand the implications of using such a "hack".

Thank you very much for the plug-in that you posted a link to. Will look into it, at if we use it, I will report about other deprecated code if it exists.
Much appreciated
Title: Re: create_function in Sources/Subs.php - errors in log_errors table - PHP 7.2.0
Post by: Chen Zhen on March 28, 2018, 08:38:47 PM
Quote from: bongobongo
Well, that code snippet I posted in my previous post in this thread stopped all errors caused by the create_function not to be logged.

I was referring to the PHP error log and not the SMF error log.
Even though you suppress the errors in the SMF log with that edit, they are being processed & piling up in your PHP error log.
Use phpinfo() to see the path of the PHP error log and have a look.
The control panel will likely have that on its command menu as an icon/link.

You're welcome for the plug-in and I hope it proves useful.
I'll admit that I was a bit lazy with it as it parses large portions of code at times to cover multiple edits instead of more concentrated individual edits.
This was due to the amount of edits that were necessary.

@vbgamer45
I am thinking the team here is more than likely going to push SMF 2.1 instead of updating the SMF 2.0.X branch for PHP 7.2+.

Title: Re: create_function in Sources/Subs.php - errors in log_errors table - PHP 7.2.0
Post by: vbgamer45 on March 28, 2018, 09:42:01 PM
I think they will will do the 7.2 for the SMF 2.0.x they generally do an update to fix people issues for still supported versions and 2.0 will be supported for a long time.
Title: Re: create_function in Sources/Subs.php - errors in log_errors table - PHP 7.2.0
Post by: bongobongo on March 29, 2018, 05:23:13 AM
You can install the following plug-in that will fix some of the code:
https://web-develop.ca/index.php?action=downloads;area=stable_smf_modifications;file=48

If you use it please report any other deprecated code you come across so I can add it.
It alters all the create_functions to anonymous and changes some other code due to newer syntax.

I installed the MOD for compatibility with PHP 7.2, and it looks a lot better. But got these lines in the error_log file after loading the front page. Is this something you could look into?

"[29-Mar-2018 09:16:53 UTC] PHP Deprecated:  Function create_function() is deprecated in /home/matlheth/public_html/Sources/Load.php on line 178
[29-Mar-2018 09:16:53 UTC] PHP Deprecated:  Function create_function() is deprecated in /home/matlheth/public_html/Sources/Load.php on line 183
[29-Mar-2018 09:16:53 UTC] PHP Deprecated:  Function create_function() is deprecated in /home/matlheth/public_html/Sources/Load.php on line 184
[29-Mar-2018 09:16:53 UTC] PHP Deprecated:  Function create_function() is deprecated in /home/matlheth/public_html/Sources/Load.php on line 220
[29-Mar-2018 09:16:53 UTC] PHP Deprecated:  Function create_function() is deprecated in /home/matlheth/public_html/Sources/Load.php on line 223
[29-Mar-2018 09:16:53 UTC] PHP Deprecated:  Function create_function() is deprecated in /home/matlheth/public_html/Sources/Load.php on line 235
[29-Mar-2018 09:16:53 UTC] PHP Deprecated:  Function create_function() is deprecated in /home/matlheth/public_html/Sources/Load.php on line 250
[29-Mar-2018 09:16:53 UTC] PHP Deprecated:  Function create_function() is deprecated in /home/matlheth/public_html/Sources/Load.php on line 268
[29-Mar-2018 09:16:53 UTC] PHP Deprecated:  Function create_function() is deprecated in /home/matlheth/public_html/Sources/Load.php on line 178
[29-Mar-2018 09:16:53 UTC] PHP Deprecated:  Function create_function() is deprecated in /home/matlheth/public_html/Sources/Load.php on line 183
[29-Mar-2018 09:16:53 UTC] PHP Deprecated:  Function create_function() is deprecated in /home/matlheth/public_html/Sources/Load.php on line 184
[29-Mar-2018 09:16:53 UTC] PHP Deprecated:  Function create_function() is deprecated in /home/matlheth/public_html/Sources/Load.php on line 220
[29-Mar-2018 09:16:53 UTC] PHP Deprecated:  Function create_function() is deprecated in /home/matlheth/public_html/Sources/Load.php on line 223
[29-Mar-2018 09:16:53 UTC] PHP Deprecated:  Function create_function() is deprecated in /home/matlheth/public_html/Sources/Load.php on line 235
[29-Mar-2018 09:16:53 UTC] PHP Deprecated:  Function create_function() is deprecated in /home/matlheth/public_html/Sources/Load.php on line 250
[29-Mar-2018 09:16:53 UTC] PHP Deprecated:  Function create_function() is deprecated in /home/matlheth/public_html/Sources/Load.php on line 268
Title: Re: create_function in Sources/Subs.php - errors in log_errors table - PHP 7.2.0
Post by: drewactual on March 29, 2018, 03:10:25 PM
nice lil mod!!!!

however... to the situation with your host and php7.2:

it's highly illogical you'd have access to only 7.2.x.... the packages almost always contain the family of versions- meaning 7.0.x, 7.1.x, and 7.2.x ought to be available in the same package, and them allowing you access to 7.0/.1 is a simple httpd or ini alteration.... if they won't do that, i'd consider finding someone else who will...

your version of SMF is built to work with up to 7.0, and moving to 7.1 is fairly simple and straight forward (depending on mods)- while moving to 7.2 where some components have been straight up abandoned (depreciated) causing you lots of headaches, and heading down a path where you don't know how many alterations you'll be making- making you one update away from having the same headaches. 
Title: Re: create_function in Sources/Subs.php - errors in log_errors table - PHP 7.2.0
Post by: Chen Zhen on March 29, 2018, 03:41:23 PM
For some of us it may be by choice.
Some of the newer updated classes written for PHP 7.2+ offer functions not available in previous versions.
ie. I just wrote a useful modification that requires ZipArchive class encryption.
 
@bongobongo:
I will look into your report.
Title: Re: create_function in Sources/Subs.php - errors in log_errors table - PHP 7.2.0
Post by: bongobongo on March 29, 2018, 03:52:57 PM
[...]
@bongobongo:
I will look into your report.

Thanks for that feedback.

Just a small notice:
The small report from me above only show errors generated from the Sources/Load.php file (which was the result after me loading the frontpage of the forum). Have not tested much other actually.
I also searched the whole installation package for "Full install" - for the 2.0.15, and there is something like 25 different php files in the Sources folder which uses create_function.

In the MOD package you created, which I used, it "removes" the create_function in 14 of those files.
Any plan to make it so the MOD package makes changes to the other files as well?
Title: Re: create_function in Sources/Subs.php - errors in log_errors table - PHP 7.2.0
Post by: drewactual on March 29, 2018, 03:54:49 PM
understood... and there are some things i'd like to use too... but right now the juice isn't worth the squeeze in many cases (again from my perspective).
Title: Re: create_function in Sources/Subs.php - errors in log_errors table - PHP 7.2.0
Post by: bongobongo on April 19, 2018, 06:38:20 AM

That will not stop the actual PHP error log from filling up plus there is more than just instances of create_function that cause errors.
You can install the following plug-in that will fix some of the code:
https://web-develop.ca/index.php?action=downloads;area=stable_smf_modifications;file=48

If you use it please report any other deprecated code you come across so I can add it.
It alters all the create_functions to anonymous and changes some other code due to newer syntax.

Chen Zhen:
I did report my findings to you in this thread.
Is there any updates to your code anytime soon?
Title: Re: create_function in Sources/Subs.php - errors in log_errors table - PHP 7.2.0
Post by: Chen Zhen on May 17, 2018, 11:32:40 PM
The mod has been updated to version 1.2 and replaces all deprecated code that I am able to find thus far.
If you use it and come across any issues or deprecated code that I missed then please report it on my forum.

ref.
https://web-develop.ca/index.php?topic=240.0
Title: Re: create_function in Sources/Subs.php - errors in log_errors table - PHP 7.2.0
Post by: MultiformeIngegno on October 20, 2018, 06:42:09 PM
The mod has been updated to version 1.2 and replaces all deprecated code that I am able to find thus far.
If you use it and come across any issues or deprecated code that I missed then please report it on my forum.

ref.
https://web-develop.ca/index.php?topic=240.0
Thanks for this Chen Zhen - I am using your mod successfully (0 errors for weeks). I really think SMF should release 2.0.16 with support for PHP 7.2
Title: Re: create_function in Sources/Subs.php - errors in log_errors table - PHP 7.2.0
Post by: Black Tiger on November 07, 2018, 09:15:57 PM
Looks good, thank you for this nice mod Chen Zen!
Just having errors from 2 mods now, so have to contact those if they want to upgrade for 7.2 compatibility.
I hope real SMF 7.2 support will come soone as 7.1 will only have security fixes by january 1st and EOL end of next year.
Title: Re: create_function in Sources/Subs.php - errors in log_errors table - PHP 7.2.0
Post by: Looking on December 26, 2018, 06:02:39 AM
Very good mod, installed without errors and cleared up 7.2 error messages.
Title: Re: create_function in Sources/Subs.php - errors in log_errors table - PHP 7.2.0
Post by: waxpop on March 01, 2019, 10:57:05 AM
Hi, my host is suddenly running PHP 7.2 and I'm getting the error on my SMF v2.0.15 board: "Deprecated: Function create_function() is deprecated in..." After some research, it looks like this mod is what I need but I'm getting errors during installation. The Replace ./Sources/Subs.php test failed. Any ideas?
Title: Re: create_function in Sources/Subs.php - errors in log_errors table - PHP 7.2.0
Post by: Arantor on March 01, 2019, 11:25:16 AM
Don’t run PHP 7.2 is about it at the moment.
Title: Re: create_function in Sources/Subs.php - errors in log_errors table - PHP 7.2.0
Post by: Black Tiger on March 01, 2019, 11:31:19 AM
Quote
it looks like this mod is what I need but I'm getting errors during installation. The Replace ./Sources/Subs.php test failed. Any ideas?
Since your host updated to php 7.2 there is not much you can do. If it's only errors but the mod is working, just ignore the errors.
However, you could always ask the creator of the mod if he's prepared to update his mod to php 7.2 compatibility, some codes are prepared to do that.

The only other option is to find a host which give you choices or still runs php 7.0 or 7.1.
Title: Re: create_function in Sources/Subs.php - errors in log_errors table - PHP 7.2.0
Post by: Arantor on March 01, 2019, 11:58:22 AM
SMF core reports errors on 7.2...
Title: Re: create_function in Sources/Subs.php - errors in log_errors table - PHP 7.2.0
Post by: Black Tiger on March 01, 2019, 12:48:53 PM
Yes, but not with the SMF 2.0.X - PHP 7.2+ Compatibility mod by Chen Zen mentioned in this thread. I thought he installed that too.
I'm running my SMF 2.0.15 on php 7.2 without any errors.
Title: Re: create_function in Sources/Subs.php - errors in log_errors table - PHP 7.2.0
Post by: waxpop on March 01, 2019, 01:12:25 PM
Quote
it looks like this mod is what I need but I'm getting errors during installation. The Replace ./Sources/Subs.php test failed. Any ideas?
Since your host updated to php 7.2 there is not much you can do. If it's only errors but the mod is working, just ignore the errors.
However, you could always ask the creator of the mod if he's prepared to update his mod to php 7.2 compatibility, some codes are prepared to do that.

The only other option is to find a host which give you choices or still runs php 7.0 or 7.1.

I haven't installed the mod because it warned me of the error during testing. Don't want to accidentally break my site completely!
Title: Re: create_function in Sources/Subs.php - errors in log_errors table - PHP 7.2.0
Post by: Black Tiger on March 01, 2019, 01:28:20 PM
You might want to disable all other mods first before trying to install the php 7.2 compatibility mod to be sure. Good chance the error is created by another mod.

Anyway, if you really want to stay safe without errors in your case, there is only 1 method and that is what Arantor said.
Title: Re: create_function in Sources/Subs.php - errors in log_errors table - PHP 7.2.0
Post by: Arantor on March 01, 2019, 05:29:16 PM
Yes, but not with the SMF 2.0.X - PHP 7.2+ Compatibility mod by Chen Zen mentioned in this thread. I thought he installed that too.
I'm running my SMF 2.0.15 on php 7.2 without any errors.

You probably have no other bbc mods installed, no site I ever had would work without changes that can’t be done by that mod.
Title: Re: create_function in Sources/Subs.php - errors in log_errors table - PHP 7.2.0
Post by: Black Tiger on March 01, 2019, 05:47:05 PM
Quote
You probably have no other bbc mods installed
I don't have BBC mods  (I think), but other mods:

Title: Re: create_function in Sources/Subs.php - errors in log_errors table - PHP 7.2.0
Post by: Arantor on March 01, 2019, 06:02:37 PM
Yeah, nothing that adds new bbc, which won’t (and can’t) be fixed by the patch.