Advertisement:

Author Topic: create_function in Sources/Subs.php - errors in log_errors table - PHP 7.2.0  (Read 1017 times)

Offline bongobongo

  • Semi-Newbie
  • *
  • Posts: 25
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 ?


Online Kindred

  • The Mean One
  • Support Specialist
  • SMF Legend
  • *
  • Posts: 56,480
  • Gender: Male
    • Kindred-999 on GitHub
Since SMF does not support 7.2 - no...    no effort has been made to look into that yet.
Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

Offline bongobongo

  • Semi-Newbie
  • *
  • Posts: 25
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.

Offline Antes

  • Evil Black Cat
  • SMF Friend
  • SMF Hero
  • *
  • Posts: 8,722
  • Gender: Male
  • Black cat rulz!
    • Antes on GitHub
    • merta on LinkedIn
    • @XinYenFon on Twitter
    • Lunarfall
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.
Past Project(s): [ ezPortal ]

Online Kindred

  • The Mean One
  • Support Specialist
  • SMF Legend
  • *
  • Posts: 56,480
  • Gender: Male
    • Kindred-999 on GitHub
Exactly... SMF supports php7, just not 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.

Offline bongobongo

  • Semi-Newbie
  • *
  • Posts: 25
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.


Offline Chen Zhen

  • Sophist Member
  • *****
  • Posts: 1,120
  • Gender: Male
  • If you're going through hell, keep going!
    • Underdog-01 on GitHub
    • WebDev.ca

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.
 
 

Online vbgamer45

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 20,211
    • smfhacks on Facebook
    • VBGAMER45 on GitHub
    • @createaforum on Twitter
    • SMF For Free
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

Offline bongobongo

  • Semi-Newbie
  • *
  • Posts: 25
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

Offline Chen Zhen

  • Sophist Member
  • *****
  • Posts: 1,120
  • Gender: Male
  • If you're going through hell, keep going!
    • Underdog-01 on GitHub
    • WebDev.ca
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+.


Online vbgamer45

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 20,211
    • smfhacks on Facebook
    • VBGAMER45 on GitHub
    • @createaforum on Twitter
    • SMF For Free
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

Offline bongobongo

  • Semi-Newbie
  • *
  • Posts: 25
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

Offline drewactual

  • Jr. Member
  • **
  • Posts: 250
    • College Football Fan Site CFB51
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. 
https://www.cfb51.com is a College Football Fan Site, Store, and Publisher, launched in July of 2017

Offline Chen Zhen

  • Sophist Member
  • *****
  • Posts: 1,120
  • Gender: Male
  • If you're going through hell, keep going!
    • Underdog-01 on GitHub
    • WebDev.ca
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.

Offline bongobongo

  • Semi-Newbie
  • *
  • Posts: 25
[...]
@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?
« Last Edit: March 29, 2018, 04:06:55 PM by bongobongo »

Offline drewactual

  • Jr. Member
  • **
  • Posts: 250
    • College Football Fan Site CFB51
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).
https://www.cfb51.com is a College Football Fan Site, Store, and Publisher, launched in July of 2017

Offline bongobongo

  • Semi-Newbie
  • *
  • Posts: 25

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?

Offline Chen Zhen

  • Sophist Member
  • *****
  • Posts: 1,120
  • Gender: Male
  • If you're going through hell, keep going!
    • Underdog-01 on GitHub
    • WebDev.ca
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