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
clausl
Board Member



Joined: 27 May 2019

Posts: 12



PostPosted: Wed May 29, 2019 7:18 pm 
Post subject: Re: Upgrade for PHP 7.x

Okay this is paradox. If I just leave the totally empty function in the file, execution breaks

Code:
function display_avatar_gallery($mode, &$category, &$user_id, &$email, &$current_email, &$coppa, &$username, &$email, &$new_password, &$cur_password, &$password_confirm, &$icq, &$aim, &$msn, &$yim, &$website, &$location, &$occupation, &$interests, &$signature, &$viewemail, &$notifypm, &$popup_pm, &$notifyreply, &$attachsig, &$allowhtml, &$allowbbcode, &$allowsmilies, &$hideonline, &$style, &$language, &$timezone, &$dateformat, &$session_id)
{
   
}


If I take that part out registration runs through

That got me thinking if any of the names for the variables is a reserved word in PHP7

Seems like the right path. When I used

Code:
function display_avatar_gallery($mode, &$d2, &$d3, &$d4, &$d5, &$d6, &$d7, &$d8, &$d9, &$d10, &$d11, &$d12, &$d13, &$d14, &$d15, &$d16, &$d17, &$d18, &$d19, &$d20, &$d21, &$d22, &$d23, &$d24, &$d25, &$d26, &$d27, &$d28, &$d29, &$d30, &$d40, &$d41, &$d42, &$d43)
{

   
}

?>


instead, it runs again.
Now big question, which of the 43 candidates is a reserved word in PHP7

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
Back to top
clausl
Board Member



Joined: 27 May 2019

Posts: 12



PostPosted: Thu May 30, 2019 9:58 am 
Post subject: Re: Upgrade for PHP 7.x

Thanks for the help! I switched to PHP 7.3 now for the live version of the board. Should I still encounter any issues, I'll post them here for the information of others.
Back to top
clausl
Board Member



Joined: 27 May 2019

Posts: 12



PostPosted: Tue Jun 04, 2019 9:14 pm 
Post subject: Re: Upgrade for PHP 7.x

After the first few days, I can report it is running fine without any issues.
According to Search console the average loading time for pages has been reduced by about 25%.
Back to top
drathbun
Board Member



Joined: 24 Jul 2008

Posts: 685
Location: Texas


flag
PostPosted: Wed Jun 05, 2019 9:25 pm 
Post subject: Re: Upgrade for PHP 7.x

clausl wrote:
According to Search console the average loading time for pages has been reduced by about 25%.

Always a good thing to see performance improvements! Thanks for the update.

_________________
phpBBDoctor Blog
Back to top
Salvatos
Board Member



Joined: 19 Feb 2009

Posts: 439
Location: Québec


flag
PostPosted: Thu Jun 06, 2019 2:53 am 
Post subject: Re: Upgrade for PHP 7.x

Looks like I missed a couple posts here. Good to hear you have it figured out.

clausl wrote:
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.

I'm not a pro, but I can't see a reason why you would want to include the same variable twice in a function call. Interesting catch!
Back to top
StarWolf3000
Board Member



Joined: 10 Jun 2010

Posts: 127
Location: Germany


flag
PostPosted: Thu Jun 06, 2019 6:20 am 
Post subject: Re: Upgrade for PHP 7.x

Salvatos wrote:
Looks like I missed a couple posts here. Good to hear you have it figured out.

clausl wrote:
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.

I'm not a pro, but I can't see a reason why you would want to include the same variable twice in a function call. Interesting catch!

Looks like this nonsensical "typo" dates back to the beginnings of phpBB2 and no one, not even the devs, were aware of it.
Back to top
drathbun
Board Member



Joined: 24 Jul 2008

Posts: 685
Location: Texas


flag
PostPosted: Sat Jun 08, 2019 1:03 pm 
Post subject: Re: Upgrade for PHP 7.x

I can confirm that the same issue (double pass of email parameter) exists even in my highly modified phpBB code base, which dates back quite a few years. Weird that the current version of PHP doesn't like it. It's not appropriate or useful, strictly speaking, but I can't see that it's a problem unless the calling function overloads the destination variable. That's probably why it's being checked now.

For example this:
Code:
$some_function_result = my_broken_function($a, $b)

calling this
Code:
function my_broken_function($a, $a)

...would clearly be a problem, as the second instance of $a in the parameter list would be overwritten by the second argument. In this case, both instances of the $email function argument are being passed the exact same thing, so functionally (ha, pun) it works. From a syntax perspective it's dangerous, and I am glad they are catching it now.

Thanks for sharing. After all these years, still learning something new!

_________________
phpBBDoctor Blog
Back to top
vlad77
Board Member



Joined: 31 May 2015

Posts: 74


flag
PostPosted: Sat Jul 06, 2019 9:56 am 
Post subject: Re: Upgrade for PHP 7.x

may be useful:
https://sourceforge.net/projects/mysqlwithmysqli/
https://sourceforge.net/projects/ereg-using-pcre/
If these files are included in common.php, then in the new version of php, old functions will work without problems.
Back to top
StarWolf3000
Board Member



Joined: 10 Jun 2010

Posts: 127
Location: Germany


flag
PostPosted: Sat Jul 06, 2019 9:59 am 
Post subject: Re: Upgrade for PHP 7.x

vlad77 wrote:
may be useful:
https://sourceforge.net/projects/mysqlwithmysqli/
https://sourceforge.net/projects/ereg-using-pcre/
If these files are included in common.php, then in the new version of php, old functions will work without problems.

The ereg_* okay, but I don't see any need for the mysql functions.
Back to top
Phineus
Board Member



Joined: 21 Jul 2019

Posts: 11



PostPosted: Thu Jul 25, 2019 1:32 pm 
Post subject: Re: Upgrade for PHP 7.x

Re: http://www.phpbb2refugees.com/viewtopic.php?t=2352

Vendethiel wrote:
I think it's just a lot easier to replace your mysql file with my mysqli file

config.php --> $dbms = 'mysqli';
db.php --> added a switch to handle mysqli

Loads the forum index with no significant errors. The forum runs quickly and smoothly. Just about every page displays. I have not done exhaustive testing because I experience similar problems as those described by clausl

* Posts show empty content
* Editing posts seem to hang on submit
* Profile page displays fine but the avatar gallery shows the page header without avatars
* I haven't tried registration
* I don't use the "Acronyms" mod
* I have one "Custom BBCode" for [pre] formatting (works exactly like the other BBCodes)
* I have a url truncator mod (commented out)
* Without further tweaking, can't make new posts - error in functions_search.php - I fixed this on a previous effort so I know it's not a major deal.

vlad77 wrote:
https://sourceforge.net/projects/mysqlwithmysqli/
https://sourceforge.net/projects/ereg-using-pcre/
If these files are included in common.php, then in the new version of php, old functions will work without problems.

I understand the rationale but it hasn't corrected the above noted problems. It's true, there's no split/explode or preg_replace/preg_replace_callback errors but the above issues remain.

Two things come to mind.

1. Completely bypass bbcode.php to see if posts display. If so, redeploy one function / process at a time until the error is predictable or is overcome.

2. Rewrite every bbcode.php function for preg_replace_callback. Seems to me just working around "/e" isn't enough. At this stage I think it would be nice to devise something ala ereg.inc.php but I'm not there yet. I'll have to play with some examples before I'm ready to tackle either of those files.
Back to top
ABDev
Board Member



Joined: 01 Jun 2009

Posts: 45


flag
PostPosted: Sat Jul 27, 2019 7:39 am 
Post subject: Re: Upgrade for PHP 7.x

Hi all,
I just wanted to say I'm working since a long time on a fork of phpBB2.
It actually works on PHP 7.2 and MySQL 5.7
When it will be enough advanced, I will talk more about it.



2019-07-27_09-33-50.png
 Description:
 Filesize:  95.19 KB
 Viewed:  84 Time(s)

2019-07-27_09-33-50.png


Back to top
Phineus
Board Member



Joined: 21 Jul 2019

Posts: 11



PostPosted: Sat Jul 27, 2019 10:52 am 
Post subject: Re: Upgrade for PHP 7.x

Another clue in the mystery of the vanishing post text (and user signatures too, by the way).

In viewtopic.php down around line +/- 1150 is a little function to "Replace naughty words". This function includes convoluted code as well as nested procedures that are returning an empty string for the message (and user signature) text.

I don't know why we can't use the same method that's used on the $post_subject for these other two sections ($message and $user_sig).

I also don't know why commenting out the offending lines (and/or the entire 'if' section) yields a premature end of file error and consequently a blank white page.

I don't have a fix, yet, but at least I've located a source to one of our problems. I'd welcome somebody more competent with php than myself to have a look at it, and maybe rewrite the function or find a workaround.

It's worth noting I was able to simulate the image gallery problem in a different context. But one problem at a time.
Back to top
Vendethiel
Board Member



Joined: 26 Oct 2014

Posts: 153



PostPosted: Sat Jul 27, 2019 3:09 pm 
Post subject: Re: Upgrade for PHP 7.x

If you can post the function here or on gist.github.com then I might be able to give a diagnosis.

Glad to see you still around ABDev icon_smile.gif.

_________________
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
Phineus
Board Member



Joined: 21 Jul 2019

Posts: 11



PostPosted: Sat Jul 27, 2019 9:23 pm 
Post subject: Re: Upgrade for PHP 7.x

This is the whole function.

Code:

   //
   // Replace naughty words
   //
   if (count($orig_word))
   {
      $post_subject = preg_replace($orig_word, $replacement_word, $post_subject);

      if ($user_sig != '')
      {
         $user_sig = str_replace('\"', '"', substr(@preg_replace('#(\>(((?>([^><]+|(?R)))*)\<))#se', "@preg_replace(\$orig_word, \$replacement_word, '\\0')", '>' . $user_sig . '<'), 1, -1));
      }

      $message = str_replace('\"', '"', substr(@preg_replace('#(\>(((?>([^><]+|(?R)))*)\<))#se', "@preg_replace(\$orig_word, \$replacement_word, '\\0')", '>' . $message . '<'), 1, -1));
   }
Back to top
ABDev
Board Member



Joined: 01 Jun 2009

Posts: 45


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

This is a regexp, which allows to use censors.
There is no reason it doesn't work.
Back to top
Display posts from previous:   
Register or Login to Post    Index » phpBB2 Discussion  Previous TopicPrint TopicNext Topic
Page 3 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.0337 seconds using 17 queries. (SQL 0.0022 Parse 0.0028 Other 0.0287)
phpBB Customizations by the phpBBDoctor.com
Template Design by DeLFlo and MomentsOfLight.com Moments of Light Logo