Daily Lucky Numbers:
1
4
8
25
36
43

SMF 2.0 - Enable PHP7.2+ Compatibility version 1.3

Started by Chen Zhen, May 17, 2018, 11:37:29 PM

Previous topic - Next topic

Chen Zhen

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.

Still pending:
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.

Enjoy.


Available to members only.

DOWNLOAD MODIFICATION

demlak

Hi,
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
File: ..../Sources/PersonalMessage.php

Line: 1036
Line: 967

thx in advance

Chen Zhen

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.

demlak

Thx a lot.. this was fast =)
it's working.

if you want to scare yourself.. grep for "count\(" over smf and all subfolders =)

Chen Zhen


No problem.

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?

demlak

i just wanted to say, that the count() function is used maaaaany many times in SMF and Simple-Portal

Chen Zhen


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.

streetskater

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

Chen Zhen


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

 


Skhilled

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.

Skhilled

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.

Chen Zhen


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.
 

Skhilled

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.

Chen Zhen

#13

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.

Chen Zhen


If you are using CentOS, you should be able to follow the instructions from this link:
https://web-develop.ca/index.php?topic=446.0;moderate