SMF 2.0.1.7 - PHP Deprecated: Function create_function() on PHP 7.2

Started by L2Scarlet, May 22, 2020, 05:34:18 PM

Previous topic - Next topic

L2Scarlet

Hi everyone, please some help... or any advice.. thx in advance.
As far as you know PHP 7.0 and 7.1 versions are DEPRECATED.
I updated today from 2.0.15 to 2.0.16 and then 2.0.17 and on my shared server I switched from ea-PHP71 to ea-PHP72 and even ea-PHP73 and I still get these errors.
(P.S. I have another updated SMF forum to 2.0.17 and there is no warning or error)
What can I do? I can't stay with PHP 7.1 forever...

[23-May-2020 00:24:51 Europe/Berlin] PHP Deprecated:  Function create_function() is deprecated in /home/xxxxxx/domains/xxxxxx/public_html/forum/Sources/Load.php on line 178
[23-May-2020 00:24:51 Europe/Berlin] PHP Deprecated:  Function create_function() is deprecated in /home/xxxxxx/domains/xxxxxx/public_html/forum/Sources/Load.php on line 183
[23-May-2020 00:24:51 Europe/Berlin] PHP Deprecated:  Function create_function() is deprecated in /home/xxxxxx/domains/xxxxxx/public_html/forum/Sources/Load.php on line 184
[23-May-2020 00:24:51 Europe/Berlin] PHP Deprecated:  Function create_function() is deprecated in /home/xxxxxx/domains/xxxxxx/public_html/forum/Sources/Load.php on line 220
[23-May-2020 00:24:51 Europe/Berlin] PHP Deprecated:  Function create_function() is deprecated in /home/xxxxxx/domains/xxxxxx/public_html/forum/Sources/Load.php on line 223
[23-May-2020 00:24:51 Europe/Berlin] PHP Deprecated:  Function create_function() is deprecated in /home/xxxxxx/domains/xxxxxx/public_html/forum/Sources/Load.php on line 235
[23-May-2020 00:24:51 Europe/Berlin] PHP Deprecated:  Function create_function() is deprecated in /home/xxxxxx/domains/xxxxxx/public_html/forum/Sources/Load.php on line 250
[23-May-2020 00:24:51 Europe/Berlin] PHP Deprecated:  Function create_function() is deprecated in /home/xxxxxx/domains/xxxxxx/public_html/forum/Sources/Load.php on line 252
[23-May-2020 00:24:51 Europe/Berlin] PHP Deprecated:  Function create_function() is deprecated in /home/xxxxxx/domains/xxxxxx/public_html/forum/Sources/Load.php on line 257
[23-May-2020 00:24:51 Europe/Berlin] PHP Deprecated:  Function create_function() is deprecated in /home/xxxxxx/domains/xxxxxx/public_html/forum/Sources/Load.php on line 268
[23-May-2020 00:24:51 Europe/Berlin] PHP Deprecated:  Function create_function() is deprecated in /home/xxxxxx/domains/xxxxxx/public_html/forum/Sources/Load.php on line 270
[23-May-2020 00:24:51 Europe/Berlin] PHP Deprecated:  Function create_function() is deprecated in /home/xxxxxx/domains/xxxxxx/public_html/forum/Sources/Load.php on line 273
[23-May-2020 00:24:51 Europe/Berlin] PHP Deprecated:  Function create_function() is deprecated in /home/xxxxxx/domains/xxxxxx/public_html/forum/Sources/Subs.php on line 1088



FIXED! I reinstalled the forum to latest version.


L2Scarlet

It's seems that was not fixed. I still get Deprecated on PHP 7.3
What I tried ...
1. I reinstalled a clean 2.0.17 (DB+files) - No errors or warnings on PHP 7.3!
2. I upgraded with Large upgrade.. there are deprecated on Load.php and Subs.php on PHP 7.3
3. I reinstalled a clean 2.0.17 ("my DB"+ clean files) - I get Deprecated Create_function in Subs.php and Load.php on PHP 7.3!

I don't know how to remove my mods ..  It can be from my mods Pretty URLs and Youtube crappy BB or something like that.
When I try to uninstall or remove mods I can't ... FAILED ....

All I want to keep and use is my DB. I can replace all my forum files but DB is important.
PLEASE HELP! Thanks in advance.


*** UPDATED!
This is from .../Sources/Load.php on line 178 (Function create_function() is deprecated)
There's something weird because I get these Deprecated lines ONLY on two of my SMF forums 2.0.17 which ARE NOT on Cloudflare but I have recently updated my other SMFs from 2.0.15 to 2.0.17 which ARE on Cloudflare and I don't get any Deprecated on PHP 7.3 !!! What's going on? My forums are on same physical server.
$smcFunc += array(
'entity_fix' => create_function('$string', '
$num = substr($string, 0, 1) === \'x\' ? hexdec(substr($string, 1)) : (int) $string;
return $num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF) || $num === 0x202E || $num === 0x202D ? \'\' : \'&#\' . $num . \';\';'),
'htmlspecialchars' => create_function('$string, $quote_style = ENT_COMPAT, $charset = \'ISO-8859-1\'', '
global $smcFunc;
return ' . ($utf8 ? '$smcFunc[\'fix_utf8mb4\'](' : '') . strtr($ent_check[0], array('&' => '&amp;')) . 'htmlspecialchars($string, $quote_style, ' . ($utf8 ? '\'UTF-8\'' : '$charset') . ')' . $ent_check[1] . ($utf8 ? ')' : '') . ';'),
'fix_utf8mb4' => create_function('$string', '




*** Same with PHP 7.2! Only on PHP 7.1 there are no deprecated...

Kindred

It's due to their server configuration which does not allow the suppression of the warnings
Сл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."

Sir Osis of Liver

Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

Arantor

Please let's not start that argument again over 'deprecated code' because SMF has contained actually-deprecated code for 10 years. That mod might fix the core, it won't fix any other bbc mods that will have the exact same problem.

The issue is that for some reason the error suppression isn't working as it should.

Sir Osis of Liver

Wouldn't it be better to eliminate the errors than rely on server config to suppress them?
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

Arantor

Quote from: Sir Osis of Liver on May 25, 2020, 01:00:31 PM
Wouldn't it be better to eliminate the errors than rely on server config to suppress them?


If it was possible to correctly eliminate all of them, yes. But this doesn't guarantee all of them, I'm not even sure it fixes the ones the OP is referring to, now that I look at it.

And it's not meant to be 'server config', SMF should be able to override the relevant config itself and suppress the errors - why it clearly isn't doing so correctly is anyone's guess.

Sir Osis of Liver

The errors don't seem to break anything, but they can make error log huge and bloat the database.  Someone posted a fix to suppress all create_function errors -

Errors.php



// Send the
se notices introduced by PHP 7.2 to where the sun don't shine!
if (strpos($error_string, 'create_function()') !== false)
return false;



Haven't tried it, but seems harmless.
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

SpacePhoenix

Quote from: Arantor on May 25, 2020, 01:02:03 PM
And it's not meant to be 'server config', SMF should be able to override the relevant config itself and suppress the errors - why it clearly isn't doing so correctly is anyone's guess.

xdebug has a "scream mode" which if enabled will suppress the error operator "the @ operator" and there's a scream extension which can also suppress the error operator "the @ operator". The OP should ask their host if either the scream extension is present and active or if xdebug has got the scream mode enabled

Arantor

@Sir Osis, maybe you should try it, it seems like a good idea after all.

@SpacePhoenix, yes, I know about the scream mode. I would however be very, very concerned about someone implementing scream mode on a production server. Because I'd be worried about having *XDebug* on a production server in general. It's almost never a good idea in practice. (And I say this as someone who runs XDebug as a full bloat debug-enabled setup with VSCode to set breakpoints and things. I still wouldn't be doing it in production and I wouldn't be implementing scream mode in production for sure. There are legitimate uses for @ in code, SMF even has a few beyond this.)

There's a reason Composer complains about it if present...

Advertisement: