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.

phpbb2.0.24 + php8.0

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



Joined: 08 Apr 2015

Posts: 33



PostPosted: Wed Mar 10, 2021 10:03 pm 
Post subject: Re: phpbb2.0.24 + php8.0

So I found the cause for why quoting doesn't work in php8.... it's related to a change that was recommended for php7.....

There was an adjustment to posting.php....

Pre7 line (quite possibly the original one)

Quote:


$msg_date = create_date($board_config['default_dateformat'], $postrow['post_time'], $board_config['board_timezone']);



php7 fixed line.....

Quote:


$msg_date = create_date($board_config['default_dateformat'], ( isset($postrow['post_time']) ) ? $postrow['post_time'] : '', $board_config['board_timezone']);



If I go back to the original line, quoting works again in php8, but the following errors display on the page:

Quote:


Warning: Undefined variable $postrow in/posting.php on line 1010

Warning: Trying to access array offset on value of type null in /posting.php on line 1010



So that's one mystery of what line is causing the error at least. Is there a better method to now properly define the variable, and make sure the offset works in php8?
Back to top
desertking
Board Member



Joined: 29 Mar 2021

Posts: 4



PostPosted: Mon Mar 29, 2021 12:18 pm 
Post subject: Re: phpbb2.0.24 + php8.0

Quote:
The next stack trace is for the Template_config. It's defined in my normal style (nosebleed.cfg, and subSilver.cfg) but it's still throwing error

Fatal error: Uncaught Error: Undefined constant "TEMPLATE_CONFIG" in /forums/templates/NoseBleed/NoseBleed.cfg:

Code:


nosebleed.cfg

//
// Do not alter this line!
//
define( ' TEMPLATE_CONFIG ' , TRUE);





And with all that, I've actually got the page to load..... Of course, it's probably still really, really broken, but at least now the investigation can actually start. <G>



- This did not really work for me. The problem didn't occur anymore but I get another major error: Template->make_filename(): Error - template file not found: overall_header.tpl
I use the xs_mod and don't know if something else breaks there. The files all exist but they don't find it anymore. Dunno in what path it looks maybe I can find out.

Edit: Digged a little deeper and tried to get the full path. This seems not to work in the template.php on php8 = $this->root . While in php 7.4 it gives me the full path to template file.
So this seems to be an error. But I don't know why it occurs and how I can fix it.


Also: Here is a solution for any case that can occur with "while list" in phpbb2. Helped me a lot:

    Case 1: Missing $value

    while (list($key, ) = each($array)) {
    Update to:
    foreach(array_keys($array) as $key) {

    Case 2: Missing $key

    while (list(, $value) = each($array)) {
    Update to:
    foreach($array as $value) {

    Case 3: Not missing anything

    while (list($key, $value) = each($array)) {
    Update to:
    foreach($array as $key => $value) {
Back to top
desertking
Board Member



Joined: 29 Mar 2021

Posts: 4



PostPosted: Mon Mar 29, 2021 5:31 pm 
Post subject: Re: phpbb2.0.24 + php8.0

s1eelra1 wrote:
Gonna need help with this line.... I have not found example fixes... Most are while ( list

This is just a list = each

Code:


In admin_forums.php

list($cat_id) = each($HTTP_POST_VARS['addforum']);



There's no child loop after the list, it's just a line inside the parent function.


EDIT: on another page, it gave me an error about { } not being there, so.... I just added it, {} after the foreach. Very hack solution... it seemed to work. I assume somebody will know the "real" solution for it. <G>


What was your final approach on that? Can you post the code?
Back to top
s1eelra1
Board Member



Joined: 08 Apr 2015

Posts: 33



PostPosted: Mon Mar 29, 2021 11:21 pm 
Post subject: Re: phpbb2.0.24 + php8.0

desertking wrote:
s1eelra1 wrote:
Gonna need help with this line.... I have not found example fixes... Most are while ( list

EDIT: on another page, it gave me an error about { } not being there, so.... I just added it, {} after the foreach. Very hack solution... it seemed to work. I assume somebody will know the "real" solution for it. <G>


What was your final approach on that? Can you post the code?


Thanks for posting the foreach replacements for the while( list( options.

I found some code which had just list() = each () ;.... So as a hacky work around I put it into a foreach loop. Because it follows proper for loop syntax (foreach ( ) { code goes here } ) I just added a {} on the next line after the foreach. As example:

Code:


      /*
      //-- php8 fixes
      //-- Original Line Below       
      list($cat_id) = each($HTTP_POST_VARS['addforum']);
      */
      foreach ( array_keys($HTTP_POST_VARS['addforum']) as $cat_id )
      {}

      //-- fin replace



The more I look at it, maybe it was not required. I did a search for list( when I was looking for while( list( so maybe I updated things that do not all need to be updated. I'll have to try going back to a few of those and see if I get real error messages. One was in admin_forums... but it works regardless. Although I think I might have added a {} incorrectly.
Back to top
desertking
Board Member



Joined: 29 Mar 2021

Posts: 4



PostPosted: Tue Mar 30, 2021 6:09 am 
Post subject: Re: phpbb2.0.24 + php8.0

Okay thanks I saw that line as well. But since it has an each() it needs some kind of update as you figured out correctly icon_smile.gif
I will replace it as well.



What I also found out that with PHP8 all the notice for

Notice: Undefined index / Undefined offset
Notice: Undefined variable
Notice: Trying to access array offset on value of type null

will be warnings from then on. As I still got many of these unfixed, it's time to fix them now or ignore the E_WARNINGS and don't throw them out.

At least I found a stack overflow with best practices.

https://stackoverflow.com/questions/4261133/notice-undefined-variable-notice-undefined-index-and-notice-undefined




Also in the sessions.php I had to change the braces {} to [] as I got any error there. Dunno if there are other files left with that problem. Didn't found it yet.


PHP RFC: Deprecate curly brace syntax for accessing array elements and string offsets


https://wiki.php.net/rfc/deprecate_curly_braces_array_access
Back to top
s1eelra1
Board Member



Joined: 08 Apr 2015

Posts: 33



PostPosted: Tue Mar 30, 2021 10:01 pm 
Post subject: Re: phpbb2.0.24 + php8.0

Thanks for the links. I have been trying to deal with all the index, variable, etc. As I find them.

Do you have a sample for your sessions.php fix? I'd like to see what you used.

Also I have "$match" for a variable, which doesn't work anymore. I also had some $$ which needed to be turned into ${$..... to get things like the searches to work properly.

The other few bugs I've been working on, notification emails aren't working.... and I have a really bad crash on the topic calendar mod in php8. 7.4 has some errors about indexes I think so hopefully that will help.
Back to top
desertking
Board Member



Joined: 29 Mar 2021

Posts: 4



PostPosted: Tue Apr 06, 2021 7:25 am 
Post subject: Re: phpbb2.0.24 + php8.0

In the session.php I only fixed the braces problem which came by a SEO-URL-MOD

Code:
   // Question Mark Fix: Seo Urls are disabled if the first char is a question mark. This is caused by incompatibility of some wrong written mods
      elseif ( $url{0} == '?' )


Simply changes {} to []


I can't tell you much about the matches as I changed alot of it. My search still seemed to work with the way I have it under php8. But you need to be careful with the variables and how you initialize them. Sometimes I destroyed them and the pagination doesn't seem to work anymore. Maybe the same happend to your "match". I guess it's an array.

$$ to ${$

you mean like in this case from the search.php ?

Code:
for($i = 0; $i < count($store_vars); $i++)
      {
         $store_search_data[$store_vars[$i]] = $$store_vars[$i];
      }


What does happen if you change it in that way?
Back to top
s1eelra1
Board Member



Joined: 08 Apr 2015

Posts: 33



PostPosted: Tue Apr 06, 2021 1:11 pm 
Post subject: Re: phpbb2.0.24 + php8.0

desertking wrote:

I can't tell you much about the matches as I changed alot of it. My search still seemed to work with the way I have it under php8. But you need to be careful with the variables and how you initialize them. Sometimes I destroyed them and the pagination doesn't seem to work anymore. Maybe the same happened to your "match". I guess it's an array.

$$ to ${$

you mean like in this case from the search.php ?

Code:
for($i = 0; $i < count($store_vars); $i++)
      {
         $store_search_data[$store_vars[$i]] = $$store_vars[$i];
      }


What does happen if you change it in that way?


So from what I found with 7.4 the pagination on searches was actually broken. The fix was to take the double $ and convert them at ${$. That's how I was able to fix that. Search results were impacted the most. One of the users pointed out the flaw to me... just before php8. There are some others around, but the bulk were in search.php

I don't have the SEO mod installed, but I'll go looking for them. I do have a problem with sessions.php, but it's more to with another mod (advanced time mod) especially with users logged out.

Code:

if ( $userdata['user_id'] == ANONYMOUS && isset($HTTP_COOKIE_VARS[$cookiename . '_upto']) )


Its one of those sessions vs cookies vs mismatch things.

I'll go looking for {0} anyway... maybe they got used in some other mod.
Back to top
Display posts from previous:   
Register or Login to Post    Index » phpBB2 Discussion  Previous TopicPrint TopicNext Topic
Page 2 of 2 All times are GMT
Goto page Previous  1, 2
 
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.0274 seconds using 15 queries. (SQL 0.0024 Parse 0.0008 Other 0.0242)
phpBB Customizations by the phpBBDoctor.com
Template Design by DeLFlo and MomentsOfLight.com Moments of Light Logo