SMF 2.0 - Enable PHP7.2+ Compatibility version 1.3
Version 1.3 released June 20/2018.
This update includes many more code changes to facilitate PHP 7.2+ compatibility.
Changes to ../Sources/Subs-Db-sqlite.php to replace sqlite_create_function with modern standard.
ie. PDO::sqliteCreateFunction or SQLite3::createFunction
Please uninstall and delete any previous versions prior to using this version.
Report any issues with this modification in this thread.
Available to members only.
DOWNLOAD MODIFICATION (https://web-develop.ca/index.php?action=downloads;area=stable_smf_modifications;file=48)
i'm not 100% sure if this is php7.2 related (but web research hints me in this direction). When taking a look into personal Messages there are some errors about a count-function.
2: count(): Parameter must be an array or an object that implements Countable
thx in advance
Yes the behavior of count() has changed in PHP 7.2
I implemented the changes and released a version 1.3 which you can download.
Make sure to uninstall & delete the older mod package prior to installing the new version.
Thanks for the report.
Thx a lot.. this was fast =)
if you want to scare yourself.. grep for "count\(" over smf and all subfolders =)
Quoteif you want to scare yourself.. grep for "count\(" over smf and all subfolders =)
grep? You seem to be suggesting regex to return an array that is countable.
Why not explain this statement to be clear?
i just wanted to say, that the count() function is used maaaaany many times in SMF and Simple-Portal
Normally a developer will ensure the object or array being counted is actually declared prior to counting it.
It looks like a previous developer of SMF in that particular file relied on the older behavior of count() to return 1 when not an array/object or 0 on a null object/array.
I haven't seen the warning pop up as of yet other than this example however if it does happen again then report it and I will add the edit.
As for Simple Portal, I can't say for sure but I think Sinan would have made sure objects/arrays are declared prior to counting them.
Please excuse me, I'm a little confused and this is my first time on this forum.
From the Download section I got a mod callled "SMF 2.0.X branch". That appeared to be a Patching tool that would attempt to alter existing PHP 7.2 depreciated functions calls... It seem it would try to modify my installed SFM 2.0.15. and not roll me back to SMF 2.0
What is offered here is something different, YES? This lookes like a modified version of SMF 2.0 compliant with 7.2 to replace any existing installed version of SMF, presumably a version earlier than 2.0.
BOTH are designated release 1.3
If what I downloaded is indeed a completly differnt "patch file" Where is the appropriate place for me to ask about how to deploy it. I didn't find related posts in the forum unless this is it. I'm not a total novice with SFM--been using it for quite awhile but just getting back into it again. It's been some time since I got very deep into the scripts. Aeva Media 2.10 is giving me headaches, but that's another sob story :-) For the 2.0.X Branch patch do I just upload it with Package Manager and and somehow run it, or it runs itself---doens't seem quite right but I'm not sure how else to install and run it.
Hopefully I'll be a little less newbie soon.
"SMF 2.0.X branch" is just to differentiate between the two current branches available since many now use the SMF 2.1 (or SMF 2.1.X) branch.
I did not test the patch on SMF versions previous to SMF 2.0.14 and have tested it on the current version 2.0.15 with no issues.
It does a lot of extensive file edits.
There is a possibility that it may not install without flagged parsing errors only if a modification has already altered the concerned files in the same area it attempts to edit.
Imo the areas in files it edits are not common places for other mods to have previously parsed given the current SMF hook structure.
Therefore it is likely you can install it without any parsing errors and no worries.
However, if you do encounter a parsing error during installation & are not comfortable with parsing your own edits then you can back out of the install without proceeding as with any other modification.
Try it out and if it shows everything as ok (no parsing errors) then install it.
Hi streetskater. Aeva media has been outdated and unsupported for about 5 years, more or less. There's been a number of changes to SMF's coding since then. It was a very good mod. I've used it myself for a number of years but gave up on it cause it was too outdated. That's what hackers look for...outdated software.
Just finally tested this. So far, no errors! YEAH!
However, this should be added to the docs or something similar:
"When you switch versions of PHP you will get "Service Unavailable" upon viewing your site which may last up to a few minutes depending on the speed of the server as well as your broadband. Refresh your browser after a minute or two and your site should load again and be much faster!"
A few of us had tested switching PHP versions lately without the mod and got that. You'll also get it after you install the mod. Someone reminded us about the mod but the one on vbGamer's site. But his is only for 2.1. I'll let them know about this one for 2.0.x.
Are you referring to SMF Hacks?
That is the same version for the SMF 2.0.X branch.
SMF 2.1 should not need this type of modification as it should already be compliant with PHP 7.
Was referring to both versions about the addition. But...
The one at smfhacks says for 2.0, I was wrong. I was probably thinking of Block Proxy VPN On Registration mod which is for 2.1. And yes, 7.2 and 7.3 works great with 2.1.
Did you say you are still using CentOS 6 ?
FYI PHP 7.4 is scheduled to roll out some time in November 2019.
The newer syntax for anonymous functions is very favorable for developers.
It involves a more short hand command structure.
Previous syntax should still work for it though.
If you are using CentOS, you should be able to follow the instructions from this link:
I sure am, thanks! :)
I updated that thread with one instruction I forgot to initially include.
The actual downloading of the kernel update.. oops.
It is edited now to include that command.
I have tried to apply this MOD to my forums, but the big replacement block in subs.php fails to apply automatically (as I have BBC adding plugin).
Would you consider breaking up that big block to single create_function -> anon function replacements?
That way added bbc blocks would not prevent installation.
Of course added bbc blocks would not and could not be fixed by the MOD, but the original stuff would be corrected.
Doing it that way will be a lot of work.
There are many lines to be edited and it was easier to do them in bulk.
How many bbc mods have you added?
If it is few, would you consider using one of the custom bbc mods to add them instead?
Custom bbc or personalized bbc will allow you to add bbcodes.
Since they both use hooks to add them, this will not effect the parsing of the Subs.php file.
It's only a single youtube MOD per site, but for historical reasons it's two different youtube MODs on the two forums :(
I hoped it was easy to break up the block, but if it's complicated I'll give a try to a different approach.
Hey, the SMF 2.0.16 patch seems to have fixed the cases that cause errors on PHP 7.2+, but SMF still uses deprecated functions (like create_function) and only hides them from error logging. Not my idea of PHP 7.2 support :( ... Seems your mod is still relevant. :)
I went ahead and modified your mod files so it can be applied on top of SMF 2.0.16. You can find them in the attachment zip. There still might be new code in 2.0.16 (or 2.0.17) that introduces even more deprecated code, so those should be checked before going ahead with this. Not sure if you'd like this mod to re-enable error logging for deprecations, but if so, you can search for this line in the sources:
$ssi_error_reporting = error_reporting((defined('E_STRICT') ? E_ALL | E_STRICT : E_ALL) & ~E_DEPRECATED);
Can't seem to be able to edit my last post, but here's a list of things I did with mod files:
- no longer needs each() fix
- replace fix: Added rel="noopener noreferrer" to generated bbc links
- replace fix: Added some classes for bbc
- replace fix: Use image proxy function
- replace fix: Added new gdpr section (introducing even more create_function() usage)
- remove obsolete entity replacement
- no longer needs unpack() fix
- no longer needs count() fix
Welcome to Webdev, Dankirk.
The SMF devs probably thought it would be best to come up with a solution that would allow any installed mods to also circumvent the PHP warnings.
For those that still want to have all occurrences of create_function omitted, I will work on an updated release for SMF 2.0.16+.
I'm sorry, but there is a 404 error when trying to download the PHP7.2+ compatibility mod for SMF 2.0.x.
Thanks for the report.
Version 1.4 was deleted in error at some point.
Version 1.5 is now available which will work for SMF 2.0.17 (or a few versions previous to that).
This thread has been locked.