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



Joined: 19 Nov 2008

Posts: 585
Location: North West UK


flag
PostPosted: Mon Feb 18, 2019 6:10 am 
Post subject: Re: Upgrade for PHP 7.x

For those of us that are not programmers what we could do with is a dummies step by step method of handling an "upgrade" to PHP7 so as to keep our phpBB2 boards going in the long term.

Jim

_________________
The truth is out there.
Unfortunately they will not let you anywhere near it!
Back to top
b0blee
Board Member



Joined: 11 Jun 2012

Posts: 15
Location: Cloverdale, northern California



PostPosted: Sun Feb 24, 2019 3:45 am 
Post subject: Re: Upgrade for PHP 7.x

Looking forward to this, as PHP 5.x has reached end of life. I want to upgrade my server.
_________________
-𝕓𝕆𝕓- at The Steel Guitar Forum
Back to top
clausl
Board Member



Joined: 27 May 2019

Posts: 12



PostPosted: Mon May 27, 2019 5:49 pm 
Post subject: Re: Upgrade for PHP 7.x

Hi @all

I am currently testing the possibilities to upgrade from 2.0.22 to 7.2

The mysqli.php file from Vendethiel has been a HUGE help. Thank you very much. icon_idea.gif icon_idea.gif

I tried 2 other approaches before without success.

With the file I got it running. I am now testing it and fixing the problems

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);

I have yet to find out what breaks it. It runs in 5.6 but not in 7.2. If I comment this line, registration work (but then no avatars)


I will continue testing and hopefully update this post
Back to top
drathbun
Board Member



Joined: 24 Jul 2008

Posts: 683
Location: Texas


flag
PostPosted: Mon May 27, 2019 9:14 pm 
Post subject: Re: Upgrade for PHP 7.x

There are other posts related to usercp_avatar that might provide some help. I think (it has been a while) there are some occurrences of $$ variables that are no longer supported.
_________________
phpBBDoctor Blog
Back to top
clausl
Board Member



Joined: 27 May 2019

Posts: 12



PostPosted: Tue May 28, 2019 6:59 am 
Post subject: Re: Upgrade for PHP 7.x

Thx for the feedback.
Do you mean this
http://www.phpbb2refugees.com/viewtopic.php?p=8320#8320
It seems related to phpbb3 rather than phpbb2 but the functions is a good hint. Unfortunately the solution in phpbb2 does not seem to be just to remove the ampersand fromthe function call.
Any more hints/tips?
Back to top
Vendethiel
Board Member



Joined: 26 Oct 2014

Posts: 152



PostPosted: Tue May 28, 2019 8:51 am 
Post subject: Re: Upgrade for PHP 7.x

Hi clausi,

"All posts appear empty" is an issue I also had to deal with on IntegraMOD.
I think it's related to the "Custom BBCodes" OR "Acronyms" mod. Can you confirm you have such a mod?

You can take a look at my changes here.

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



Joined: 27 May 2019

Posts: 12



PostPosted: Tue May 28, 2019 9:55 am 
Post subject: Re: Upgrade for PHP 7.x

Hi Vendethiel

I am not really sure which mods I have. I installed the forum in 2007. So long time ago.
But I really had few mods. Mainly a mod to rewrite URLs and an antispam mod to prevent bot registrations.

I took a glance at your list of changes. Seems very useful. is count_safe() a function you defined?

My main remaining problem is point 4) of my post above. I still have to figure out what goes wrong in usercp_avatar and how to fix that. Your list of changes does not include that file. Do you allow avatars on your forum

Claus
Back to top
Vendethiel
Board Member



Joined: 26 Oct 2014

Posts: 152



PostPosted: Tue May 28, 2019 8:45 pm 
Post subject: Re: Upgrade for PHP 7.x

count_safe is indeed a function I defined. It's a very small one. Just ensures we don't count() on NULL.

For the avatar, I'm surprised your issue is not the standard ampersand one.
Do you have error logs?

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



Joined: 27 May 2019

Posts: 12



PostPosted: Wed May 29, 2019 8:06 am 
Post subject: Re: Upgrade for PHP 7.x

No I don't have error logs (or I have no idea where they are or how to turn them on). The execution of the registration just stops with an empty page (unless I remove the line
include($phpbb_root_path . 'includes/usercp_avatar.'.$phpEx); )

Well maybe it is the ampersand issue and I handled it wrong? I just removed the & from the function parameters

So for example

Old:
Code:
function check_image_type(&$type, &$error, &$error_msg)


became
New
Code:
function check_image_type($type, $error, $error_msg)


and that for all functions in the file.

Or is there anything else to do related with this?
Back to top
Vendethiel
Board Member



Joined: 26 Oct 2014

Posts: 152



PostPosted: Wed May 29, 2019 8:57 am 
Post subject: Re: Upgrade for PHP 7.x

It's not the right place. These ampersands have to stay.
They should be removed from the method calls. If you can pastebin me the file (or gist.github.com) then I'll take a look.

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



Joined: 27 May 2019

Posts: 12



PostPosted: Wed May 29, 2019 9:04 am 
Post subject: Re: Upgrade for PHP 7.x

P.S. Posted this before I saw your previous reply. The ampersands are removed from the function parameters

I narrowed it down. Something in this function breaks it. If I remove the function from the code registration goes through

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)
{
   global $board_config, $db, $template, $lang, $images, $theme, $abq_config;
   global $phpbb_root_path, $phpEx;

   $dir = @opendir($board_config['avatar_gallery_path']);

   $avatar_images = array();
   while( $file = @readdir($dir) )
   {
      if( $file != '.' && $file != '..' && !is_file($board_config['avatar_gallery_path'] . '/' . $file) && !is_link($board_config['avatar_gallery_path'] . '/' . $file) )
      {
         $sub_dir = @opendir($board_config['avatar_gallery_path'] . '/' . $file);

         $avatar_row_count = 0;
         $avatar_col_count = 0;
         while( $sub_file = @readdir($sub_dir) )
         {
            if( preg_match('/(\.gif$|\.png$|\.jpg|\.jpeg)$/is', $sub_file) )
            {
               $avatar_images[$file][$avatar_row_count][$avatar_col_count] = $sub_file;
               $avatar_name[$file][$avatar_row_count][$avatar_col_count] = ucfirst(str_replace("_", " ", preg_replace('/^(.*)\..*$/', '\1', $sub_file)));

               $avatar_col_count++;
               if( $avatar_col_count == 5 )
               {
                  $avatar_row_count++;
                  $avatar_col_count = 0;
               }
            }
         }
      }
   }

   @closedir($dir);

   @ksort($avatar_images);
   @reset($avatar_images);

   if( empty($category) )
   {
      list($category, ) = each($avatar_images);
   }
   @reset($avatar_images);

   $s_categories = '<select name="avatarcategory">';
   while( list($key) = each($avatar_images) )
   {
      $selected = ( $key == $category ) ? ' selected="selected"' : '';
      if( count($avatar_images[$key]) )
      {
         $s_categories .= '<option value="' . $key . '"' . $selected . '>' . ucfirst($key) . '</option>';
      }
   }
   $s_categories .= '</select>';

   $s_colspan = 0;
   for($i = 0; $i < count($avatar_images[$category]); $i++)
   {
      $template->assign_block_vars("avatar_row", array());

      $s_colspan = max($s_colspan, count($avatar_images[$category][$i]));

      for($j = 0; $j < count($avatar_images[$category][$i]); $j++)
      {
         $template->assign_block_vars('avatar_row.avatar_column', array(
            "AVATAR_IMAGE" => $board_config['avatar_gallery_path'] . '/' . $category . '/' . $avatar_images[$category][$i][$j],
            "AVATAR_NAME" => $avatar_name[$category][$i][$j])
         );

         $template->assign_block_vars('avatar_row.avatar_option_column', array(
            "S_OPTIONS_AVATAR" => $avatar_images[$category][$i][$j])
         );
      }
   }


   for($i = 0; $i < count($params); $i++)
   {
      $s_hidden_vars .= '<input type="hidden" name="' . $params[$i] . '" value="' . str_replace('"', '&quot;', $$params[$i]) . '" />';
   }
   
   $template->assign_vars(array(
      'L_AVATAR_GALLERY' => $lang['Avatar_gallery'],
      'L_SELECT_AVATAR' => $lang['Select_avatar'],
      'L_RETURN_PROFILE' => $lang['Return_profile'],
      'L_CATEGORY' => $lang['Select_category'],

      'S_CATEGORY_SELECT' => $s_categories,
      'S_COLSPAN' => $s_colspan,
      'S_PROFILE_ACTION' => append_sid("profile.$phpEx?mode=$mode"),
      'S_HIDDEN_FIELDS' => $s_hidden_vars)
   );

   return;
}


Any ideas?
Back to top
clausl
Board Member



Joined: 27 May 2019

Posts: 12



PostPosted: Wed May 29, 2019 9:06 am 
Post subject: Re: Upgrade for PHP 7.x

Vendethiel wrote:
count_safe is indeed a function I defined. It's a very small one. Just ensures we don't count() on NULL.



Could you maybe share the count_safe you wrote? Just want to make sure I do this right. Thx.
Back to top
clausl
Board Member



Joined: 27 May 2019

Posts: 12



PostPosted: Wed May 29, 2019 9:11 am 
Post subject: Re: Upgrade for PHP 7.x

Vendethiel wrote:
It's not the right place. These ampersands have to stay.
They should be removed from the method calls. If you can pastebin me the file (or gist.github.com) then I'll take a look.


Thanks for your reply. I have to admit I do not know what a 'method call' is? The place that calls the defined function?
Back to top
Salvatos
Board Member



Joined: 19 Feb 2009

Posts: 439
Location: Québec


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

Correct. Looking back, my post you linked to didn't make that very clear although the PHP reference I pointed to explained it. Basically, you want to:
- keep the ampersands in the function definition (function fname (&$params) {...});
- remove the ampersands from the function call (fname ($params)).

PHP wrote:
Note: There is no reference sign on a function call - only on function definitions. Function definitions alone are enough to correctly pass the argument by reference. As of PHP 5.3.0, you will get a warning saying that "call-time pass-by-reference" is deprecated when you use & in foo(&$a);. And as of PHP 5.4.0, call-time pass-by-reference was removed, so using it will raise a fatal error.
Back to top
clausl
Board Member



Joined: 27 May 2019

Posts: 12



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

Salvatos wrote:
Correct. Looking back, my post you linked to didn't make that very clear although the PHP reference I pointed to explained it. Basically, you want to:
- keep the ampersands in the function definition (function fname (&$params) {...});
- remove the ampersands from the function call (fname ($params)).



Thank you very much for the clarification!
However than this cannot be the cause as there are no &$ in function calls in both usercp_avatar.php and usercp_register.php

I suspect it could be a cause of the count() function? What exactly would I need to replace this with to be safe?

I really appreciate all your help.
Back to top
Display posts from previous:   
Register or Login to Post    Index » phpBB2 Discussion  Previous TopicPrint TopicNext Topic
Page 2 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.0339 seconds using 15 queries. (SQL 0.0024 Parse 0.0009 Other 0.0306)
phpBB Customizations by the phpBBDoctor.com
Template Design by DeLFlo and MomentsOfLight.com Moments of Light Logo