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!
Suggested Hosts
User avatar
DionDesigns
Registered User
Posts: 515
Joined: Sun Feb 26, 2012 11:22 pm
Location: Uncertain due to momentum.
Contact:

Re: PHP7 and the preg_replace problem

Post by DionDesigns »

First time logging in here in a LONG time...
AmigoJack wrote:So PHP7 disables /e, but Dion fixes this by using eval()? That's what e was standing for all along. Good luck to those environments where this function is disabled.
I suggest you run the following command on the phpBB 3.1 (or 3.2) directory:

Code: Select all

grep -rnw phpBB -e "eval("
It would appear that phpBB itself would not run if eval() was disabled, so this is a straw man argument. If eval() is safe enough to use in Twig and Symfony, it's safe anough to use in BBcode parsing.

As for the second comment, you are more than welcome to your opinion that the code is outdated. It may even be a valid criticism -- I don't know and I honestly don't care. Do you see any errors in the code? (I'm aware that converting to entities could create an SQL error if someone used 25 or so emojis in a topic title or forum name. I thought about changing the DB schema from VARCHAR(255) to VARCHAR(512), but for some reason phpBB still supports MySQL 4.x which does not allow VARCHAR values greater than 255.)

In any case, I came up with a solution that works. Is it perfect? Of course not...so please feel free to improve on it. ;)
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 »

My fault. I'm neither familiar with Twig nor Symfony. But I also found out even phpBB3.0 uses eval() (modules, PMs, template), so this really isn't an argument I can use.
  • "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
WelshPaul
Registered User
Posts: 420
Joined: Tue Aug 19, 2014 2:09 pm

Re: PHP7 and the preg_replace problem

Post by WelshPaul »

I've been looking through the code changes and my database today after implementing this on a test board using php 7.0.1 and it works just fine. Noticeable speed increase too!

Your initial comment about eval() is moot, as already pointed out by Dion and later yourself.

As for your second comment, Well they may be outdated approaches but that doesn't mean they shouldn't be used or can't be used. phpBB isn't exactly set to always use the latest and greatest either...

For example, the MySQL table schema and support code in phpBB 3.1 is the original stuff written by "Oleg" for phpBB 3.0 in 2005!!! It is designed to support MySQL 3.23+, which is more than 12 years old! If the MySQL table schema and mysqli DB driver were updated for MySQL 5.1.40+ (still five years old), phpBB would run faster and be significantly more stable.
User avatar
Marc
Development Team Leader
Development Team Leader
Posts: 5657
Joined: Tue Oct 30, 2007 10:57 pm
Location: Munich, Germany
Name: Marc
Contact:

Re: PHP7 and the preg_replace problem

Post by Marc »

WelshPaul wrote:For example, the MySQL table schema and support code in phpBB 3.1 is the original stuff written by "Oleg" for phpBB 3.0 in 2005!!! It is designed to support MySQL 3.23+, which is more than 12 years old! If the MySQL table schema and mysqli DB driver were updated for MySQL 5.1.40+ (still five years old), phpBB would run faster and be significantly more stable.
The Oleg you seem to be talking about did not contribute anything to phpBB prior to 2010 and barely even touched anything related to the DBAL. The DBAL was largely refactored in 3.1 to support autoloading as well as newer database versions like the latest MySQL, MariaDB, and SQLite 3. Of course phpBB was updated for MySQL 5.1.40+ as well as MySQL 5.4, 5.5, 5.6, and even 5.7.
If you think there are any speed improvements that can be achieved by breaking compatibility with older versions, I welcome you to post that in our Tracker or discuss it on Area51.

To be honest, phpBB might actually be incompatible with MySQL 3.23 right now. I don't think any of us have tested it with that version in a long time so it might be better to increase the minimum version at some point.
User avatar
DavidIQ
Customisations Team Leader
Customisations Team Leader
Posts: 18316
Joined: Thu Jan 06, 2005 1:30 pm
Location: Fishkill, NY
Name: David Colón
Contact:

Re: PHP7 and the preg_replace problem

Post by DavidIQ »

WelshPaul wrote:Noticeable speed increase too!
That's due to PHP 7, not the code changes, and should be completely expected since speed and efficiency was one of the things the PHP developers focused on.
Apply to become a Jr. Extension Validator
My extensions | In need of phpBB services? | Was I helpful today?
No unsolicited PMs unless you're planning on asking for paid help.
User avatar
WelshPaul
Registered User
Posts: 420
Joined: Tue Aug 19, 2014 2:09 pm

Re: PHP7 and the preg_replace problem

Post by WelshPaul »

DavidIQ wrote:That's due to PHP 7, not the code changes, and should be completely expected since speed and efficiency was one of the things the PHP developers focused on.
I know it's due to php 7. I didn't say it was because of the code changes. :roll:

I was simply trying to point out that running phpBB 3.1.x on php 7 results in a noticeable speed increase without writing a paragraph on why. :)

Edit: Sorry for all the edits, iPhone > predictive text!
Last edited by WelshPaul on Tue Nov 08, 2016 8:50 pm, edited 4 times in total.
User avatar
WelshPaul
Registered User
Posts: 420
Joined: Tue Aug 19, 2014 2:09 pm

Re: PHP7 and the preg_replace problem

Post by WelshPaul »

Marc wrote:If you think there are any speed improvements that can be achieved by breaking compatibility with older versions, I welcome you to post that in our Tracker or discuss it on Area51.
I might just do that. ;)
vns990
Registered User
Posts: 1
Joined: Tue Jan 03, 2017 2:41 pm

Re: PHP7 and the preg_replace problem

Post by vns990 »

PHP71PHPBB_Error.JPG
This occurred during using different themes in phpBB3.
Work around don't use older theme types if using 7.* or be prepared to rollback if able to a v5.* if you're forced to keep old coding.

Putting the theme back to default and de activating such themes fixed the issue for the time being.
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 »

It's not style related (unless the style executes PHP). Your warnings most supposely come from the (unmodified) PHP code in the database table for the BBCode.
  • "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
Marc
Development Team Leader
Development Team Leader
Posts: 5657
Joined: Tue Oct 30, 2007 10:57 pm
Location: Munich, Germany
Name: Marc
Contact:

Re: PHP7 and the preg_replace problem

Post by Marc »

The mentioned warnings are from phpBB 3.1 which is known to not be fully PHP 7.x compatible. That's what we'll have phpBB 3.2 for.
zag2me
Registered User
Posts: 15
Joined: Wed Jan 18, 2012 10:13 am

Re: PHP7 and the preg_replace problem

Post by zag2me »

Thanks for the temporary hack, it really helps us all who can't use 3.2 because of incompatible styles.

Working fine here on PHP 7
andrewilley
Registered User
Posts: 114
Joined: Fri Sep 12, 2008 7:28 pm
Location: Birmingham UK
Contact:

Re: PHP7 and the preg_replace problem

Post by andrewilley »

I'm running phpBB 3.0.14 on a very small PHP setup, and although I looked at upgrading to 3.1.x or 3.2.x a while back they appeared to break a lot of connected code that I was using, most crucially some PHP that I found here and modified a long time back which runs on the Homepage and News page and is used to display simplified content from a specific forum as a 'news update' system. See www.portorleans.org (right-hand column) and www.portorleans.org/news.php for an idea of what the code does.

This has been working perfectly for a number of years, but now my hosting company went and installed PHP 7 with MySQLi, and that seemed to break my whole site. They've rolled me back to PHP 5.6 for now, but are insisting that by the end of September they will be removing 5.6 completely.

Does anyone know of a workable solution to allow my current site to work under PHP 7? Otherwise there is going to be a shed-load of work to do! Mine is not a commercial site, only a spare-time thing, and I don't even know if I'm able to re-write that code anyway as much of it was originally posted in messages here and I only made minor changes that were within my fairly limited skill set. The annoying thing is that under PHP 5.6 it works perfectly just the way it is. :(

Andre
--- Admin of www.portorleans.org
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 »

One option could be to find a host that is still running PHP 5.6 and move your site - there are plenty of them out there. That would at the very least give you some breathing space to get your site ready for PHP7 - which will inevitable come with all hosts sooner or later.
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
WelshPaul
Registered User
Posts: 420
Joined: Tue Aug 19, 2014 2:09 pm

Re: PHP7 and the preg_replace problem

Post by WelshPaul »

andrewilley wrote: Thu Aug 31, 2017 2:42 pm I'm running phpBB 3.0.14 on a very small PHP setup, and although I looked at upgrading to 3.1.x or 3.2.x a while back they appeared to break a lot of connected code that I was using, most crucially some PHP that I found here and modified a long time back which runs on the Homepage and News page and is used to display simplified content from a specific forum as a 'news update' system. See www.portorleans.org (right-hand column) and www.portorleans.org/news.php for an idea of what the code does.

This has been working perfectly for a number of years, but now my hosting company went and installed PHP 7 with MySQLi, and that seemed to break my whole site. They've rolled me back to PHP 5.6 for now, but are insisting that by the end of September they will be removing 5.6 completely.

Does anyone know of a workable solution to allow my current site to work under PHP 7? Otherwise there is going to be a shed-load of work to do! Mine is not a commercial site, only a spare-time thing, and I don't even know if I'm able to re-write that code anyway as much of it was originally posted in messages here and I only made minor changes that were within my fairly limited skill set. The annoying thing is that under PHP 5.6 it works perfectly just the way it is. :(

Andre
Setup a VPS and you can run php 5.6 for as long as you want. Sooner or later though, you'll need to upgrade!
User avatar
open-your-eyes
Registered User
Posts: 94
Joined: Mon Jul 31, 2017 8:20 am
Contact:

Re: PHP7 and the preg_replace problem

Post by open-your-eyes »

I am also running a few 3.0.14 boards.
AmigoJack wrote: Wed Nov 02, 2016 8:21 am
No, as that doesn't fix custom BBCodes. Like I commented in PHPBB3-13857 parsing the PHP code stored in the database would be one way to solve this. Currently I do this for 1+ month on a 3.0.14 installation and it works without any flaw.
Can you please tell me what to do? My PHP version is 5.6.31, but sooner or later, my host will upgrade. :(
Post Reply

Return to “phpBB Discussion”