Page 1 of 6

PHP7 and the preg_replace problem

Posted: Sun May 17, 2015 10:47 am
by Frank Rizzo
I note the bugtracker records for this problem such as here:

https://tracker.phpbb.com/browse/PHPBB3-13832

The issue is that 3.0.x and 3.1.x are using preg_replace with the /e modifier, which is deprecated in PHP7.

Why Use PHP7? It is still in Beta.
1. The release is only a few months away.
2. Out of the box - as a direct drop in replacement - code runs ~15% faster 8-) This can be very desirable for some boards.
3. Some boards on shared hosting may find in a few months that their hosters have upgraded to PHP7 and their board will be broken. Hosters will be tempted to do this because of 2. above.

What is being done to fix it?
I get the impression that it is 'too much hassle' to fix for 3.1 and that rewritten code in 3.2 will do away with the problem.

The question then is: When will 3.2 be released? Can us early PHP7 adopters run 3.2 today? (I know the caveat about running alpha / beta on production sites but this is up to the individual).

If 3.2 is not available yet then how can the code be fixed manually? Is it just a matter of finding all instances of preg_replace with the /e modifier and changing the code to the more upto date format? Or could this break other parts of phpbb?

Re: PHP7 and the preg_replace problem

Posted: Sun May 17, 2015 10:51 am
by david63
Frank Rizzo wrote:The question then is: When will 3.2 be released?
The last I heard on this was that 3.2 is scheduled for November 2015 - see viewtopic.php?f=14&t=2302466

Re: PHP7 and the preg_replace problem

Posted: Sun May 17, 2015 1:05 pm
by Oyabun1

Re: PHP7 and the preg_replace problem

Posted: Sun May 17, 2015 2:35 pm
by Lumpy Burgertushie
and I wouldn't hold my breath expecting hosters to upgrade to php7 any time soon. we still have the problem with many hosts still running php5.2
many , many are running 5.3.3
there are relatively few that I have seen that are even running 5.5 or even 5.6

now, what happened to php6 and all of its version updates ?

hosters are terrible about updating their software.

robert

Re: PHP7 and the preg_replace problem

Posted: Sun May 17, 2015 3:27 pm
by LavIgor
Lumpy Burgertushie wrote:now, what happened to php6 and all of its version updates ?
PHP 7 will be released after PHP 5 just like Windows 10 will be released after Windows 8.1. :D

Re: PHP7 and the preg_replace problem

Posted: Sun May 17, 2015 5:39 pm
by nicofuma
Well...

As said above I don't think that so much hoster will update to php7 soon (or at least without providing an option to choose between an up to date version of php5 and php7). Some are still proposing php4.... (and sometimes it's even the default...)

About making 3.1 php7 compatible it's really a hard work. All existing call to preg_replace with the /e modifier have to be replaced by call_replace_callback. The logic isn't the same and there is too much calls to replace, it's not just 1 or 2.... (anyway, if someone wants to spend some time on this and send a PR he is welcome)

Otherwise, 3.2 should be released at the end of the year, around November. This version should already be compatible with php7 for a new board but it's not for an existing board which already have some posts (they all have to be converted and this part isn't already available).

You can find the code on Github, the master branch is for 3.2. But I strongly advice you to not install it on a live board before we have upgraded Area51 which should happen soon.

By the way, if you update a board don't hesitate to fill bug reports in the tracker everytime you encounter a bug ;)

P.S About PHP6, you can find the answer on google^^

Re: PHP7 and the preg_replace problem

Posted: Mon May 18, 2015 9:31 am
by AmigoJack
Frank Rizzo wrote:preg_replace with the /e modifier, which is deprecated in PHP7
It was deprecated since PHP 5.5.0 already, which was released on 2013-06-20 - so why screaming now and not back then? Same question to the developers: why not adapting code since then? :roll:

Re: PHP7 and the preg_replace problem

Posted: Mon May 18, 2015 10:27 am
by Elsensee
AmigoJack wrote:
Frank Rizzo wrote:preg_replace with the /e modifier, which is deprecated in PHP7
It was deprecated since PHP 5.5.0 already, which was released on 2013-06-20 - so why screaming now and not back then? Same question to the developers: why not adapting code since then? :roll:
It worked. :P
And we wanted to integrate a new bbcode parser anyway. ;)

Re: PHP7 and the preg_replace problem

Posted: Mon May 18, 2015 11:21 am
by Frank Rizzo
It might have been deprecated in 5.5 but the failure does not exsit in 5.5 or 5.6. Only in version 7 does phpbb break.

Whether hosters ugprade to 7 or not a lot of individuals will. Believe me the performance gains (in speed and memory) are relatively huge. As I said, a straight drop in will give an instant ~15% boost in performance.

I really need php7 for one part of a site I have. But that site is also running the forum. For that reason I can not upgrade to php7.

I bet by December this forum will be crying out for PHP7. It really is a huge shift in performance. Once admins see how easy it is to upgrade and how they can run a more efficient server there will be a demand.

And may I pre-empt: "have you tried increasing your ram, tuning mysql, upgrading your CPU". Been there, done that, got the t-shirt. The next step is PHP7 (aka PHP-NG) Upgrading to PHP7 is one of the easiest things you can do to get a decent increase in performance. If anyone has a server that is not running phpbb I can recommend giving it a go (caveat about beta etc.)

Re: PHP7 and the preg_replace problem

Posted: Mon May 18, 2015 11:35 am
by Frank Rizzo
Note that all of the errors I have seen so far with PHP7 and 3.1.4 are due to BBCODES.

Posting a plain message is fine, editing a plain message is fine. But if you try and post a new message with BBCODE, or if you go back and edit an existing message (such as editing to [ b ] some text [ /b ] then you get an error:

[phpbb Debug] PHP Warning: in file [ROOT]/includes/message_parser.php on line 86: preg_replace(); The /e modifier is no longer supported, use preg_replace_callback instead

The posting / editing fails with "Your message contains too few characters"

Thus I think this could be easy to fix if the preg_replace code is changed to a newer format.

Re: PHP7 and the preg_replace problem

Posted: Mon May 18, 2015 11:39 am
by AmigoJack
Frank Rizzo wrote:the failure does not exsit in 5.5 or 5.6. Only in version 7 does phpbb break.
Then it's not deprecated in PHP 7 but instead it's not supported anymore - that's a major difference. Why don't you quote what really happens, i.e. a notice, a warning, an error...? Edit: ah, finally: a warning about a non support.

Show me a (PHP 7) changelog and I can tell you if fixing preg_replace() is the only thing that needs to be done (which is rather trivial).
Frank Rizzo wrote:a lot of individuals will
A lot of of shared hosters won't. Reason? All those legacy software, which is also the reason why up to today PHP 4 still exists. How can one benefit from performance boost (of the master) if the (slave) software in question won't run at all anymore?

Re: PHP7 and the preg_replace problem

Posted: Mon May 18, 2015 12:10 pm
by Frank Rizzo
Does anyone want to try and find a solution to this? Or shall we just sit talking semantics and be non productive all day?

Re: PHP7 and the preg_replace problem

Posted: Mon May 18, 2015 12:17 pm
by AmigoJack
AmigoJack wrote:Show me a (PHP 7) changelog and I can tell you if fixing preg_replace() is the only thing that needs to be done (which is rather trivial).
"Trivial" is a reference to "fixing preg_replace()", not "Show me a (PHP 7) changelog".

Re: PHP7 and the preg_replace problem

Posted: Sat May 23, 2015 1:45 pm
by A_Jelly_Doughnut
Frank Rizzo wrote:Does anyone want to try and find a solution to this? Or shall we just sit talking semantics and be non productive all day?
This week there was a pull request added that will address this problem (for the built-in BBCodes, custom BBCodes require further work). The fix will be merged into "develop" - the branch that is expected to become 3.2 late this year.

Re: PHP7 and the preg_replace problem

Posted: Thu Jun 11, 2015 7:30 am
by Cin-
A_Jelly_Doughnut wrote:
Frank Rizzo wrote:Does anyone want to try and find a solution to this? Or shall we just sit talking semantics and be non productive all day?
This week there was a pull request added that will address this problem (for the built-in BBCodes, custom BBCodes require further work). The fix will be merged into "develop" - the branch that is expected to become 3.2 late this year.

Any idea if it is merged already? (the part that can convert old posts), I'd like to test it on my board?