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 » Mon Nov 07, 2016 7:04 pm

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: 4890
Joined: Tue Jun 15, 2010 11:33 am
Location: グリーン ヒル ゾーン
Contact:

Re: PHP7 and the preg_replace problem

Post by AmigoJack » Tue Nov 08, 2016 2:52 pm

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 worst thing about censorship is ███████████

User avatar
WelshPaul
Registered User
Posts: 194
Joined: Tue Aug 19, 2014 2:09 pm

Re: PHP7 and the preg_replace problem

Post by WelshPaul » Tue Nov 08, 2016 3:46 pm

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: 5227
Joined: Tue Oct 30, 2007 10:57 pm
Location: Munich, Germany
Name: Marc
Contact:

Re: PHP7 and the preg_replace problem

Post by Marc » Tue Nov 08, 2016 7:35 pm

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.
Quickedit for phpBB 3.1
I'm available for custom work - just send me a PM for a quote.

User avatar
DavidIQ
Customisations Team Leader
Customisations Team Leader
Posts: 16436
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 » Tue Nov 08, 2016 7:40 pm

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: 194
Joined: Tue Aug 19, 2014 2:09 pm

Re: PHP7 and the preg_replace problem

Post by WelshPaul » Tue Nov 08, 2016 8:23 pm

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: 194
Joined: Tue Aug 19, 2014 2:09 pm

Re: PHP7 and the preg_replace problem

Post by WelshPaul » Tue Nov 08, 2016 8:25 pm

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 » Tue Jan 03, 2017 2:54 pm

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: 4890
Joined: Tue Jun 15, 2010 11:33 am
Location: グリーン ヒル ゾーン
Contact:

Re: PHP7 and the preg_replace problem

Post by AmigoJack » Tue Jan 03, 2017 5:36 pm

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 worst thing about censorship is ███████████

User avatar
Marc
Development Team Leader
Development Team Leader
Posts: 5227
Joined: Tue Oct 30, 2007 10:57 pm
Location: Munich, Germany
Name: Marc
Contact:

Re: PHP7 and the preg_replace problem

Post by Marc » Tue Jan 03, 2017 5:45 pm

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.
Quickedit for phpBB 3.1
I'm available for custom work - just send me a PM for a quote.

zag2me
Registered User
Posts: 12
Joined: Wed Jan 18, 2012 10:13 am

Re: PHP7 and the preg_replace problem

Post by zag2me » Sun Jan 22, 2017 5:30 pm

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: 74
Joined: Fri Sep 12, 2008 7:28 pm
Location: Birmingham UK
Contact:

Re: PHP7 and the preg_replace problem

Post by andrewilley » 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
--- Admin of www.portorleans.org

User avatar
david63
Jr. Extension Validator
Posts: 12824
Joined: Thu Dec 19, 2002 8:08 am
Location: Lancashire, UK
Name: David Wood
Contact:

Re: PHP7 and the preg_replace problem

Post by david63 » Thu Aug 31, 2017 2:47 pm

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!
My CDB Contributions | How to install an extension
I will not be accepting translations for any of my extensions in Github - please post any translations in the appropriate topic.
No support requests via PM or email or as they will be ignored

User avatar
WelshPaul
Registered User
Posts: 194
Joined: Tue Aug 19, 2014 2:09 pm

Re: PHP7 and the preg_replace problem

Post by WelshPaul » Thu Aug 31, 2017 3:49 pm

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!

Post Reply

Return to “phpBB Discussion”

Who is online

Users browsing this forum: No registered users and 22 guests

cron