2023-02-05, 02:16 AM
(This post was last modified: 2023-02-12, 01:17 PM by HLFadmin. Edited 3 times in total.)
I have successfully upgraded production forum to 1.8.33. Using PHP 7.4 without problems.
After cloning production server for testing purposes using PHP 8.0.27, I am going through and finding warnings. Most occur in plugins.
If I create a post containing a youtube video with a url in the form of https://youtu.be/YfdLh0MHqKw, I get the following messages.
Warning [2] Undefined array key "fragment" - Line: 1494 - File: inc/class_parser.php PHP 8.0.27 (Linux)
Warning [2] Undefined array key "query" - Line: 1505 - File: inc/class_parser.php PHP 8.0.27 (Linux)
Warning [2] Undefined array key 1 - Line: 1510 - File: inc/class_parser.php PHP 8.0.27 (Linux)
Warning [2] Undefined array key 0 - Line: 1587 - File: inc/class_parser.php PHP 8.0.27 (Linux)
Warning [2] Undefined array key "v" - Line: 1591 - File: inc/class_parser.php PHP 8.0.27 (Linux)
I note that line 1485 of inc/class_parser.php uses a native PHP function in the function mycode_parse_video() starting line 1470.
$parsed_url = @parse_url(urldecode($url));
The url does not contain a fragment in line 1494, or a query in line 1505, hence there are no $input keys in line 1510, unable to test the empty fragment array in 1587, as well as testing the $input array in 1591.
First, what purpose does line 1480 have? I think it is superfluous. Defined but not used.
1480 $bbdomain = parse_url($mybb->settings['bburl'], PHP_URL_HOST);
I made several modifications to the mycode_parse_video() function, although unable to post code in its entirety. Community only permits a single video per post, and cannot distinguish examples in comments.
Now, all three variations display.
youtu[dot]be/YfdLh0MHqKw
www[dot]youtube[dot]com/watch?v=YfdLh0MHqKw
www[dot]youtube[dot]com/watch#!v=YfdLh0MHqKw
I've had to obfuscate URLs used as explanation, including the ones used as examples in the code comments.
lines altered as below. By adding three lines, last two line numbers are pushed down.
Continuing with checking the warnings. I intend all that I find to be documented in this thread.
If you are using a plugin which relies on PluginLibrary, you'll need to upgrade to an updated version.
Thanks to SvePu. https://community.mybb.com/thread-237593...pid1383414
When searching for Today's Posts
Warning [2] Undefined array key "lastread" - Line: 476 - File: search.php PHP 8.0.27 (Linux)
Warning [2] Undefined property: MyLanguage::$pages - Line: 2 - File: search.php(567) : eval()'d code PHP 8.0.27 (Linux)
The first is fixed in line 476 of search.php
Change
[edited for correct logic]
The second is apparently fixed by editing template forumdisplay_thread_multipage from
or by adding an element to search.lang.php
I stuck it in the blank line space at line 10 to maintain consistency with other MultiPage formats.
If you are using the absolutetime plugin by doylecc, which is fantastic already, you'll need to modify it so that it does not generate a warning under PHP 8.0 in ACP / Plugins page. If present, but not active, warning is given for undefined array key 'absolutetime'
Change
to
After cloning production server for testing purposes using PHP 8.0.27, I am going through and finding warnings. Most occur in plugins.
If I create a post containing a youtube video with a url in the form of https://youtu.be/YfdLh0MHqKw, I get the following messages.
Warning [2] Undefined array key "fragment" - Line: 1494 - File: inc/class_parser.php PHP 8.0.27 (Linux)
Warning [2] Undefined array key "query" - Line: 1505 - File: inc/class_parser.php PHP 8.0.27 (Linux)
Warning [2] Undefined array key 1 - Line: 1510 - File: inc/class_parser.php PHP 8.0.27 (Linux)
Warning [2] Undefined array key 0 - Line: 1587 - File: inc/class_parser.php PHP 8.0.27 (Linux)
Warning [2] Undefined array key "v" - Line: 1591 - File: inc/class_parser.php PHP 8.0.27 (Linux)
I note that line 1485 of inc/class_parser.php uses a native PHP function in the function mycode_parse_video() starting line 1470.
$parsed_url = @parse_url(urldecode($url));
The url does not contain a fragment in line 1494, or a query in line 1505, hence there are no $input keys in line 1510, unable to test the empty fragment array in 1587, as well as testing the $input array in 1591.
First, what purpose does line 1480 have? I think it is superfluous. Defined but not used.
1480 $bbdomain = parse_url($mybb->settings['bburl'], PHP_URL_HOST);
I made several modifications to the mycode_parse_video() function, although unable to post code in its entirety. Community only permits a single video per post, and cannot distinguish examples in comments.
Now, all three variations display.
youtu[dot]be/YfdLh0MHqKw
www[dot]youtube[dot]com/watch?v=YfdLh0MHqKw
www[dot]youtube[dot]com/watch#!v=YfdLh0MHqKw
I've had to obfuscate URLs used as explanation, including the ones used as examples in the code comments.
lines altered as below. By adding three lines, last two line numbers are pushed down.
1494 if(array_key_exists('fragment', $parsed_url)) //core edit fixes error if no 'fragment' in $parsed_url
1499 if(array_key_exists('query', $parsed_url)) //core edit added to fix if no 'query' in $parsed_url
1500 { //core edit added for if statement
1516 } //core edit added for if statement
1590 if(isset($fragments[0])) //core edit to fix when $fragments is empty
1594 elseif(isset($input['v'])) // core edit to fix when $input is empty
Continuing with checking the warnings. I intend all that I find to be documented in this thread.
If you are using a plugin which relies on PluginLibrary, you'll need to upgrade to an updated version.
Thanks to SvePu. https://community.mybb.com/thread-237593...pid1383414
When searching for Today's Posts
Warning [2] Undefined array key "lastread" - Line: 476 - File: search.php PHP 8.0.27 (Linux)
Warning [2] Undefined property: MyLanguage::$pages - Line: 2 - File: search.php(567) : eval()'d code PHP 8.0.27 (Linux)
The first is fixed in line 476 of search.php
Change
if($thread['lastread'])
to if(isset($thread['lastread']))
[edited for correct logic]
if(isset($thread['lastread']) && $thread['lastread'])
The second is apparently fixed by editing template forumdisplay_thread_multipage from
<span class="smalltext">({$lang->pages} {$threadpages}{$morelink})</span>
to <span class="smalltext">({$threadpages}{$morelink})</span>
or by adding an element to search.lang.php
$l['pages'] = "Pages";
I stuck it in the blank line space at line 10 to maintain consistency with other MultiPage formats.
If you are using the absolutetime plugin by doylecc, which is fantastic already, you'll need to modify it so that it does not generate a warning under PHP 8.0 in ACP / Plugins page. If present, but not active, warning is given for undefined array key 'absolutetime'
Change
if (absolutetime_is_installed()
&& is_array($plugins_cache)
&& is_array($plugins_cache['active'])
&& $plugins_cache['active']['absolutetime'] // this line errors
) {
if (absolutetime_apply() !== true) {
$absolutetime_info['description'] .= '<br /><span style="color:red; font-size:1.2em;">'
.$lang->at_warn_core_edit.'</span>';
}
to
if (empty($plugins_cache) || !is_array($plugins_cache)) {
$plugins_cache = $cache->read('plugins');
}
$active_plugins = $plugins_cache['active'];
if (absolutetime_is_installed()
&& is_array($plugins_cache)
&& is_array($plugins_cache['active'])
&& !empty($active_plugins['absolutetime'])
) {
if (absolutetime_apply() !== true) {
$absolutetime_info['description'] .= '<br /><span style="color:red; font-size:1.2em;">'
.$lang->at_warn_core_edit.'</span>';
}