PHP7 and the preg_replace problem

Do not post support requests, bug reports or feature requests. Discuss phpBB here. Non-phpBB related discussion goes in General Discussion!
Scam Warning
Frank Rizzo
Registered User
Posts: 149
Joined: Sun Jan 05, 2003 11:10 pm
Contact:

PHP7 and the preg_replace problem

Post 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?
User avatar
david63
Registered User
Posts: 20646
Joined: Thu Dec 19, 2002 8:08 am

Re: PHP7 and the preg_replace problem

Post 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
David
Remember: You only know what you know and - you don't know what you don't know!

I now no longer support any of my extensions but they will start to become available here
User avatar
Oyabun1
Former Team Member
Posts: 23162
Joined: Sun May 17, 2009 1:05 pm
Location: Australia
Name: Bill

Re: PHP7 and the preg_replace problem

Post by Oyabun1 »

                      Support Request Template
3.0.x: Knowledge Base Styles Support MOD Requests
3.1.x: Knowledge BaseStyles SupportExtension Requests
User avatar
Lumpy Burgertushie
Registered User
Posts: 69223
Joined: Mon May 02, 2005 3:11 am
Contact:

Re: PHP7 and the preg_replace problem

Post 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
Premium phpBB 3.3 Styles by PlanetStyles.net

I am pleased to announce that I have completed the first item on my bucket list. I have the bucket.
LavIgor
Registered User
Posts: 545
Joined: Mon Apr 28, 2014 1:47 pm

Re: PHP7 and the preg_replace problem

Post 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
nicofuma
3.2 Release Manager
3.2 Release Manager
Posts: 546
Joined: Sun Apr 13, 2014 1:47 am
Location: Grenoble - France

Re: PHP7 and the preg_replace problem

Post 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^^
Member of phpBB Development-Team
No Support via PM
User avatar
AmigoJack
Registered User
Posts: 6108
Joined: Tue Jun 15, 2010 11:33 am
Location: グリーン ヒル ゾーン
Contact:

Re: PHP7 and the preg_replace problem

Post 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:
  • "The problem is probably not my English but you do not want to understand correctly. ... We will not come anybody anyway, nevertheless, it's best to shit this." Affin, 2018-11-20
  • "But this shit is not here for you. You can follow with your. Maybe the question, instead, was for you, who know, so you shoved us how you are." axe70, 2020-10-10
  • "My reaction is not to everyone, especially to you." Raptiye, 2021-02-28
User avatar
Elsensee
Former Team Member
Posts: 124
Joined: Sat May 07, 2011 11:04 am
Location: Hamburg, Germany
Name: Oliver Schramm
Contact:

Re: PHP7 and the preg_replace problem

Post 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. ;)
Former Development Team Member
I don't make bugs - I make features
Frank Rizzo
Registered User
Posts: 149
Joined: Sun Jan 05, 2003 11:10 pm
Contact:

Re: PHP7 and the preg_replace problem

Post 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.)
Frank Rizzo
Registered User
Posts: 149
Joined: Sun Jan 05, 2003 11:10 pm
Contact:

Re: PHP7 and the preg_replace problem

Post 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.
User avatar
AmigoJack
Registered User
Posts: 6108
Joined: Tue Jun 15, 2010 11:33 am
Location: グリーン ヒル ゾーン
Contact:

Re: PHP7 and the preg_replace problem

Post 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?
  • "The problem is probably not my English but you do not want to understand correctly. ... We will not come anybody anyway, nevertheless, it's best to shit this." Affin, 2018-11-20
  • "But this shit is not here for you. You can follow with your. Maybe the question, instead, was for you, who know, so you shoved us how you are." axe70, 2020-10-10
  • "My reaction is not to everyone, especially to you." Raptiye, 2021-02-28
Frank Rizzo
Registered User
Posts: 149
Joined: Sun Jan 05, 2003 11:10 pm
Contact:

Re: PHP7 and the preg_replace problem

Post 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?
User avatar
AmigoJack
Registered User
Posts: 6108
Joined: Tue Jun 15, 2010 11:33 am
Location: グリーン ヒル ゾーン
Contact:

Re: PHP7 and the preg_replace problem

Post 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".
  • "The problem is probably not my English but you do not want to understand correctly. ... We will not come anybody anyway, nevertheless, it's best to shit this." Affin, 2018-11-20
  • "But this shit is not here for you. You can follow with your. Maybe the question, instead, was for you, who know, so you shoved us how you are." axe70, 2020-10-10
  • "My reaction is not to everyone, especially to you." Raptiye, 2021-02-28
User avatar
A_Jelly_Doughnut
Former Team Member
Posts: 34459
Joined: Sat Jan 18, 2003 1:26 am
Location: Where the Rivers Run
Contact:

Re: PHP7 and the preg_replace problem

Post 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.
A Donut's Blog
"Bach's Prelude (Cello Suite No. 1) is driving Indiana country roads in Autumn" - Ann Kish
Cin-
Registered User
Posts: 55
Joined: Fri Feb 06, 2015 2:06 pm

Re: PHP7 and the preg_replace problem

Post 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?
Post Reply

Return to “phpBB Discussion”