phpBB2Refugees.com Logo
Not affiliated with or endorsed by the phpBB Group

Register •  Login 

Continue the legacy...

Welcome to all phpBB2 Refugees!Wave Smilie

This site is intended to continue support for the legacy 2.x line of the phpBB2 bulletin board package. If you are a fan of phpBB2, please, by all means register, post, and help us out by offering your suggestions. We are primarily a community and support network. Our secondary goal is to provide a phpBB2 MOD Author and Styles area.

PHP7 migration: magic_quotes


 
Search this topic... | Search Knowledge Base (KB)... | Search Box
Register or Login to Post    Index » Knowledge Base (KB)  Previous TopicPrint TopicNext Topic
Author Message
Vendethiel
Board Member



Joined: 26 Oct 2014

Posts: 136



PostPosted: Mon Feb 18, 2019 1:10 pm 
Post subject: PHP7 migration: magic_quotes

First part of the "phpBB2 to PHP7 migration" guide.
This one is for the magic quotes feature, that errors out on recent PHPs.

For history's sake: back when PHP was much younger, a lot of people misused some of its features, which led to well-known SQL injection issues. So PHP introduced a feature to try and protect from them: it inserted \ before every ' so you wouldn't break out of SQL queries.
This is the reason for a whole lot of "preg_replace" in the whole of phpBB's $sql code.

Since this feature was server-dependant, there's code in common.php to detect whether it's enabled or not. This code errors out in PHP7+.

OPEN
Code:
common.php

FIND & REMOVE
Code:
set_magic_quotes_runtime(0); // Disable magic_quotes_runtime

FIND
Code:
if( !get_magic_quotes_gpc() )

REPLACE WITH
Code:
if (true)
Back to top
Jim_UK
Board Member



Joined: 19 Nov 2008

Posts: 585
Location: North West UK


flag
PostPosted: Mon Feb 18, 2019 2:28 pm 
Post subject: Re: PHP7 migration: magic_quotes

If all the changes are applied to the code we have now and we are still running on PHP5 will the board still run or can those changes only be applied when we have to go to PHP7?
I am going to copy all the posts you make into a file ready for the day my host says I have to move to PHP7

Jim
Back to top
Vendethiel
Board Member



Joined: 26 Oct 2014

Posts: 136



PostPosted: Mon Feb 18, 2019 3:40 pm 
Post subject: Re: PHP7 migration: magic_quotes

This change is compatible with any PHP version you know has magic_quotes disabled.

This feature was deprecated in 5.3.0, from 2009. But AFAIK, the feature was disabled by default on most hosts starting with PHP4 (released in 2000).
If for some reason you absolutely must support PHP4, there's a way to make it work as well, but it'd make zero sense to.
Back to top
Phineus
Board Member



Joined: 21 Jul 2019

Posts: 11



PostPosted: Thu Jul 25, 2019 1:11 pm 
Post subject: Re: PHP7 migration: magic_quotes

I don't know if there's an advantage to one way or the other.

OPEN
Code:

common.php

FIND
Code:

set_magic_quotes_runtime(0); // Disable magic_quotes_runtime

REPLACE WITH
Code:

if (!function_exists('set_magic_quotes_runtime')) {
    function set_magic_quotes_runtime($new_setting) {
        return true;
    }
}
Back to top
Vendethiel
Board Member



Joined: 26 Oct 2014

Posts: 136



PostPosted: Sat Jul 27, 2019 3:07 pm 
Post subject: Re: PHP7 migration: magic_quotes

Your version is not enough (since get_ function is still called), and I’d rather just remove old outdated code rather than reintroduce a dummy function
Back to top
Phineus
Board Member



Joined: 21 Jul 2019

Posts: 11



PostPosted: Sun Jul 28, 2019 1:12 am 
Post subject: Re: PHP7 migration: magic_quotes

Understood. Thanks.
Back to top
Display posts from previous:   
Register or Login to Post    Index » Knowledge Base (KB)  Previous TopicPrint TopicNext Topic
Page 1 of 1 All times are GMT
 
Jump to:  

Index • About • FAQ • Rules • Privacy • Search •  Register •  Login 
Not affiliated with or endorsed by the phpBB Group
Powered by phpBB2 © phpBB Group
Generated in 0.0254 seconds using 15 queries. (SQL 0.0021 Parse 0.0008 Other 0.0226)
phpBB Customizations by the phpBBDoctor.com
Template Design by DeLFlo and MomentsOfLight.com Moments of Light Logo