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.

Upgrade for PHP 7.x

Goto page Previous  1, 2, 3, 4, 5  Next
 
Search this topic... | Search phpBB2 Discussion... | Search Box
Register or Login to Post    Index » phpBB2 Discussion  Previous TopicPrint TopicNext Topic
Author Message
StarWolf3000
Board Member



Joined: 10 Jun 2010

Posts: 127
Location: Germany


flag
PostPosted: Sun Jul 28, 2019 8:07 am 
Post subject: Re: Upgrade for PHP 7.x

ABDev wrote:
This is a regexp, which allows to use censors.
There is no reason it doesn't work.

Well, in that special case it doesn't work: The e modifier is deprecated since 5.5.0 and removed as of 7.0.0. Because error handling of preg_replace is muted with @ in front, there is no error output.
https://www.php.net/manual/en/reference.pcre.pattern.modifiers.php
Back to top
ABDev
Board Member



Joined: 01 Jun 2009

Posts: 45


flag
PostPosted: Sun Jul 28, 2019 5:00 pm 
Post subject: Re: Upgrade for PHP 7.x

Yes, you are right. I replied too quickly ...
I had forgotten I didn't use anymore this feature in my fork.
Back to top
StarWolf3000
Board Member



Joined: 10 Jun 2010

Posts: 127
Location: Germany


flag
PostPosted: Mon Jul 29, 2019 4:41 am 
Post subject: Re: Upgrade for PHP 7.x

The censor part needs to be rewritten using preg_replace_callback, as its still useful for generating shortlinks.
Back to top
jtrumpfheller
Board Member



Joined: 05 Aug 2019

Posts: 11
Location: Berlin


flag
PostPosted: Wed Aug 28, 2019 7:02 am 
Post subject: Re: Upgrade for PHP 7.x

clausl wrote:
...
1) for some reason all posts showed empty content.
I fixed that by removing the 'Replace naughty words' part from viewtopic.php which I do not use anyway
2) bbcode.php
The preg_replace with e modifier is discontinued in PHP 7.
Code:
$text = preg_replace("#\[img\]((http|ftp|https|ftps)://)([^ \?&=\#\"\n\r\t<]*?(\.(jpg|jpeg|gif|png)))\[/img\]#sie", "'[img:$uid]\\1' . str_replace(' ', '%20', '\\3') . '[/img:$uid]'", $text);

So this no longer works. I need to replace that with preg_replace_callback
The code I used to replace it is a bit awkward, but works
Code:

   $teil1="#\[img\]((http|ftp|https|ftps):..)([^ \?&=\#\"\n\r\t<]*?(\.(jpg|jpeg|gif|png)))\[.img\]#si";
   $text = preg_replace_callback($teil1, function($matches) { return '[img:' . 'h176ju' . ']' . $matches[1] . str_replace(' ', '%20', $matches[3]) . '[/img:' . 'h176ju' . ']'; }, $text);
   $text = str_replace('h176ju',$uid,$text);


3) count ($x) in PHP 7.2. can cause errors. I think the correct way is to check before with is_array($x) to ensure $x is an array

4) Registration no longer works - profile.php displays an empty page after data is entered. That obviously would be a showstopper for the migration if no fix is found
seems it stops execution at this point in usercp_register.php
Code:
   
   include($phpbb_root_path . 'includes/usercp_avatar.'.$phpEx);

...


Thanks all the people here who are looking for solutions to keep the phpBB2 run. I use it now since 2004 (Solaris template and some mods like antispam, Priority sorting - and some in between - I can't remember all)

I made the modifications now to my forum with Vendethiels mysqli - script (config.php and includes/db.php), changed the part in the includes/bbcode.php like clausl described - wonderful: It's running
But Point 3 (count_safe() ???) and 4 is still a mysterious for me, where to change?

Can anyone summarize it here where the minimum changes have to made? This would be phantastic.

_________________
any % of U is as good as the whole pie - George Clinton
https://www.spearhead-home.com

Joerg
Back to top
Vendethiel
Board Member



Joined: 26 Oct 2014

Posts: 153



PostPosted: Wed Aug 28, 2019 9:38 am 
Post subject: Re: Upgrade for PHP 7.x

Hey!

Actually, count_safe isn't "necessary". It just suppresses warnings, when trying to take the length of something that's not actually countable (which phpBB does often).

_________________
Developer on EzArena, the ADR premod.
Developer on Icy Phoenix, the phpBB hybrid cms.
Developer on IntegraMOD, the full-featured premod.
Help me archive premods on github! (fixed for recent PHPs).
Back to top
jtrumpfheller
Board Member



Joined: 05 Aug 2019

Posts: 11
Location: Berlin


flag
PostPosted: Thu Aug 29, 2019 6:47 am 
Post subject: Re: Upgrade for PHP 7.x

Hey Vendethiel,

yes that's right but anyway - how does your function looks like - where to place and do I have to replace count() than?

And what do I have to replace that register and avatar will run?

_________________
any % of U is as good as the whole pie - George Clinton
https://www.spearhead-home.com

Joerg
Back to top
Vendethiel
Board Member



Joined: 26 Oct 2014

Posts: 153



PostPosted: Thu Aug 29, 2019 11:36 am 
Post subject: Re: Upgrade for PHP 7.x

Every update I did usually ends up on IntegraMOD.
Here it is!

_________________
Developer on EzArena, the ADR premod.
Developer on Icy Phoenix, the phpBB hybrid cms.
Developer on IntegraMOD, the full-featured premod.
Help me archive premods on github! (fixed for recent PHPs).
Back to top
jtrumpfheller
Board Member



Joined: 05 Aug 2019

Posts: 11
Location: Berlin


flag
PostPosted: Thu Aug 29, 2019 5:21 pm 
Post subject: Re: Upgrade for PHP 7.x

clausl wrote:

FOUND IT:

Quote:
function display_avatar_gallery($mode, &$category, &$user_id, &$email, &$current_email, &$coppa, &$username, &$email, &$new_password, ...


The parameter &$email is used TWICE in the function. I have no idea why this is valid in PHP5.6? Is this a genuine programming error in the initial version or is there any sense to that.
If I rename one of them to ยง&email2 it runs through


Hey clausi,

it also works when you just drop out one $email-var from the function display_avatar_gallery and the call display_avatar_gallery.

_________________
any % of U is as good as the whole pie - George Clinton
https://www.spearhead-home.com

Joerg
Back to top
jtrumpfheller
Board Member



Joined: 05 Aug 2019

Posts: 11
Location: Berlin


flag
PostPosted: Tue Sep 03, 2019 12:26 pm 
Post subject: Re: Upgrade for PHP 7.x

New problem: After I tested it successfull on my local-machine/environment (win10) with
Apache/2.4.37 (Win32)
PHP/7.3.9
mysqlnd 5.0.12-dev

I uploaded the modified files to my server and changed my php-properties from 5.6.40 to 7.3.8 (the last version I can select) and I got immediately an error page 500.
The log-files gives me this message:
Quote:
AH01071: Got error 'PHP message: PHP Fatal error: Uncaught Error: Call to undefined function set_magic_quotes_runtime() in .../phpBB2/common.php:29\nStack trace:\n#0 .../phpBB2/index.php(26): include()\n#1 {main}\n thrown in .../phpBB2/common.php on line 29'


in common.php I find this:
Code:
if(version_compare(PHP_VERSION, '5.3.0', '<'))
{
   set_magic_quotes_runtime(0); // Disable magic_quotes_runtime
}


so it should run. Shouldn't it?

_________________
any % of U is as good as the whole pie - George Clinton
https://www.spearhead-home.com

Joerg
Back to top
StarWolf3000
Board Member



Joined: 10 Jun 2010

Posts: 127
Location: Germany


flag
PostPosted: Tue Sep 03, 2019 12:30 pm 
Post subject: Re: Upgrade for PHP 7.x

jtrumpfheller wrote:
New problem: After I tested it successfull on my local-machine/environment (win10) with
Apache/2.4.37 (Win32)
PHP/7.3.9
mysqlnd 5.0.12-dev

I uploaded the modified files to my server and changed my php-properties from 5.6.40 to 7.3.8 (the last version I can select) and I got immediately an error page 500.
The log-files gives me this message:
Quote:
AH01071: Got error 'PHP message: PHP Fatal error: Uncaught Error: Call to undefined function set_magic_quotes_runtime() in .../phpBB2/common.php:29\nStack trace:\n#0 .../phpBB2/index.php(26): include()\n#1 {main}\n thrown in .../phpBB2/common.php on line 29'


in common.php I find this:
Code:
if(version_compare(PHP_VERSION, '5.3.0', '<'))
{
   set_magic_quotes_runtime(0); // Disable magic_quotes_runtime
}


so it should run. Shouldn't it?

set_magic_quotes_runtime() is deprecated since 5.3.0 and removed as of 7.0.0. So you can remove this block of code entirely.
Back to top
jtrumpfheller
Board Member



Joined: 05 Aug 2019

Posts: 11
Location: Berlin


flag
PostPosted: Tue Sep 03, 2019 12:36 pm 
Post subject: Re: Upgrade for PHP 7.x

StarWolf3000 wrote:
set_magic_quotes_runtime() is deprecated since 5.3.0 and removed as of 7.0.0. So you can remove this block of code entirely.

I know but I just wonder why the if clause doesn't work?

_________________
any % of U is as good as the whole pie - George Clinton
https://www.spearhead-home.com

Joerg
Back to top
StarWolf3000
Board Member



Joined: 10 Jun 2010

Posts: 127
Location: Germany


flag
PostPosted: Tue Sep 03, 2019 1:02 pm 
Post subject: Re: Upgrade for PHP 7.x

jtrumpfheller wrote:
I know but I just wonder why the if clause doesn't work?

I have no idea. version_compare() with three parameters returns a boolean, while the method with only two parameters returns an integer (which is either -1, 0 or 1). Since phpBB2 uses the three parameters variant, it should work as condition in an if statement.
Back to top
Vendethiel
Board Member



Joined: 26 Oct 2014

Posts: 153



PostPosted: Tue Sep 03, 2019 2:03 pm 
Post subject: Re: Upgrade for PHP 7.x

FWIW here's my version of code:

Code:
if (function_exists('set_magic_quotes_runtime'))
{
  @set_magic_quotes_runtime(0); // Disable magic_quotes_runtime
}

_________________
Developer on EzArena, the ADR premod.
Developer on Icy Phoenix, the phpBB hybrid cms.
Developer on IntegraMOD, the full-featured premod.
Help me archive premods on github! (fixed for recent PHPs).
Back to top
StarWolf3000
Board Member



Joined: 10 Jun 2010

Posts: 127
Location: Germany


flag
PostPosted: Tue Sep 03, 2019 2:23 pm 
Post subject: Re: Upgrade for PHP 7.x

Vendethiel wrote:
FWIW here's my version of code:

Code:
if (function_exists('set_magic_quotes_runtime'))
{
  @set_magic_quotes_runtime(0); // Disable magic_quotes_runtime
}

This should actually work without muting the function call (since it doesn't exist on >= 7.0.0, and its only muting for >= 5.3.0 < 7.0.0, if the error_reporting is set to include E_DEPRECATED). And muting is just bad coding practice, proper error state handling should be the way to go.

The proper way to handle all PHP versions should be the following (yeah, it uses muting too, so don't judge me on that):
Code:
if (function_exists('set_magic_quotes_runtime')) { // lock out PHP 7.0.0 and higher
  if(version_compare(PHP_VERSION, '5.3.0') >= 0) { // check if between PHP 5.3.0 and 5.6.40 to prevent E_DEPRECATED kicking in
    @set_magic_quotes_runtime(0); // Disable magic_quotes_runtime
  } else {
    set_magic_quotes_runtime(0); // Disable magic_quotes_runtime
  }
}


If you don't care about PHP older than 7.0.0, then just remove the block entirely.
Back to top
Vendethiel
Board Member



Joined: 26 Oct 2014

Posts: 153



PostPosted: Tue Sep 03, 2019 9:27 pm 
Post subject: Re: Upgrade for PHP 7.x

This is a stopgap mesure for code written 15 years ago about a stupid php ini default value set 20 years ago in servers with 10-years-old PHP installations...
I think I'm gonna go and say that it really doesn't matter that @ isn't good code practice icon_razz.gif
This parts wants removed ASAP anyway.

_________________
Developer on EzArena, the ADR premod.
Developer on Icy Phoenix, the phpBB hybrid cms.
Developer on IntegraMOD, the full-featured premod.
Help me archive premods on github! (fixed for recent PHPs).
Back to top
Display posts from previous:   
Register or Login to Post    Index » phpBB2 Discussion  Previous TopicPrint TopicNext Topic
Page 4 of 5 All times are GMT
Goto page Previous  1, 2, 3, 4, 5  Next
 
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.0286 seconds using 15 queries. (SQL 0.0019 Parse 0.0009 Other 0.0258)
phpBB Customizations by the phpBBDoctor.com
Template Design by DeLFlo and MomentsOfLight.com Moments of Light Logo