News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

create_function in Sources/Subs.php - errors in log_errors table - PHP 7.2.0

Started by bongobongo, March 28, 2018, 08:48:23 AM

Previous topic - Next topic

bongobongo

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 ?


Kindred

Since SMF does not support 7.2 - no...    no effort has been made to look into that yet.
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

bongobongo

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.

Antes

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.

Kindred

Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

bongobongo

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:


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.


Chen Zhen


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.


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

Chen I would recommend that patch to the SMF team looks very good!
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

bongobongo

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

Chen Zhen

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


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

bongobongo

Quote from: Chen Zhen on March 28, 2018, 04:43:14 PM
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

drewactual

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. 

Chen Zhen

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.

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

bongobongo

Quote from: Chen Zhen on March 29, 2018, 03:41:23 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?

drewactual

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

bongobongo

Quote from: 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.

Chen Zhen:
I did report my findings to you in this thread.
Is there any updates to your code anytime soon?

Chen Zhen

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

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

MultiformeIngegno

Quote from: 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
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
RockCiclopedia (wiki - forum), Tutta la storia del rock, scritta da voi ...
Rimanere aggiornati sul mondo della musica grazie al nuovo feed "RockCiclopedia Music News"!

Black Tiger

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.
Greetings, Black Tiger

Advertisement: