MyBB Community Forums

Full Version: "Undefined array key" errors after upgrading from php-7.4 to php-8.0
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
I'm running myBB-1.8.32 on a Linux server, with php-8.0.26. After upgrading from php-7.4.x to 8.0.x, viewing one of the pre-existing posts on the forum (which happens to include a youtube video reference) is spewing a bunch of "Undefined array key" errors:

Type: 2
File: inc/class_parser.php (Line no. 1494)
Message
Undefined array key "fragment"
Back Trace: 
#0  errorHandler->email_error(2, Undefined array key "fragment", inc/class_parser.php, 1494) called at [/var/www/html/dv/inc/class_error.php:229]
#1  errorHandler->error(2, Undefined array key "fragment", inc/class_parser.php, 1494) called at [/var/www/html/dv/inc/class_error.php:153]
#2  errorHandler->error_callback(2, Undefined array key "fragment", /var/www/html/dv/inc/class_parser.php, 1494) called at [/var/www/html/dv/inc/class_parser.php:1494]
#3  postParser->mycode_parse_video(youtube, https://youtu.be/mBy6wHPeHbE) called at [/var/www/html/dv/inc/class_parser.php:1640]
#4  postParser->mycode_parse_video_callback(Array ([0] => [CENSORED],[1] => youtube,[2] => https://CENSORED))
#5  preg_replace_callback(#\[video=(.*?)\](.*?)\[/video\]#i, Array ([0] => postParser Object ([mycode_cache] => Array ([standard] => Array ([find] => Array ([0] => #\[b\](.*?)\[/b\]#si,[1] => #\[u\](.*?)\[/u\]#si,[2] => #\[i\](.*?)\[/i\]#si,[3] => #\[s\](.*?)\[/s\]#si,[4] => #\[hr\]#si,[5] => #\(c\)#i,[6] => #\(tm\)#i,[7] => #\(r\)#i),[replacement] => Array ([0] => <span style="font-weight: bold;" class="mycode_b">$1</span>,[1] => <span style="text-decoration: underline;" class="mycode_u">$1</span>,[2] => <span style="font-style: italic;" class="mycode_i">$1</span>,[3] => <span style="text-decoration: line-through;" class="mycode_s">$1</span>,[4] => <hr class="mycode_hr" />,[5] => &copy;,[6] => ™,[7] => &reg;)),[nestable] => Array ([0] => Array ([find] => #\[color=([a-zA-Z]*|\#?[\da-fA-F]{3}|\#?[\da-fA-F]{6})](.*?)\[/color\]#si,[replacement] => <span style="color: $1;" class="mycode_color">$2</span>),[1] => Array ([find] => #\[size=(xx-small|x-small|small|medium|large|x-large|xx
 -large)\](.*?)\[/size\]#si,[replacement] => <span style="font-size: $1;" class="mycode_size">$2</span>),[2] => Array ([find] => #\[align=(left|center|right|justify)\](.*?)\[/align\]#si,[replacement] => <div style="text-align: $1;" class="mycode_align">$2</div>)),[callback] => Array ([0] => Array ([find] => #\[url\]((?!javascript)[a-z]+?://)([^
"<]+?)\[/url\]#si,[replacement] => Array ([0] => postParser Object ( *RECURSION*,[1] => mycode_parse_url_callback1)),[1] => Array ([find] => #\[url\]((?!javascript:)[^
"<]+?)\[/url\]#i,[replacement] => Array ([0] => postParser Object ( *RECURSION*,[1] => mycode_parse_url_callback2)),[2] => Array ([find] => #\[url=((?!javascript)[a-z]+?://)([^
"<]+?)\](.+?)\[/url\]#si,[replacement] => Array ([0] => postParser Object ( *RECURSION*,[1] => mycode_parse_url_callback1)),[3] => Array ([find] => #\[url=((?!javascript:)[^
"<]+?)\](.+?)\[/url\]#si,[replacement] => Array ([0] => postParser Object ( *RECURSION*,[1] => mycode_parse_url_callback2)),[4] => Array ([find] => #\[size=([0-9\+\-]+?)\](.*?)\[/size\]#si,[replacement] => Array ([0] => postParser Object ( *RECURSION*,[1] => mycode_handle_size_callback))),[nestable_callback] => Array ([0] => Array ([find] => #\[font=\s*("?)([a-z0-9 ,\-_'"]+)\1\s*\](.*?)\[/font\]#si,[replacement] => Array ([0] => postParser Object ( *RECURSION*,[1] => mycode_parse_font_callback))),[standard_count] => 2,[callback_count] => 2,[nestable_count] => 3,[nestable_callback_count] => 1),[smilies_cache] => Array ([:)] => <img src="https://dv.netllama.us/dv/images/smilies/smile.png" alt="Smile" title="Smile" class="smilie smilie_1" />,[;)] => <img src="https://dv.netllama.us/dv/images/smilies/wink.png" alt="Wink" title="Wink" class="smilie smilie_2" />,[&amp;)] => &amp;),[&lt;)] => &lt;),[&gt;)] => &gt;),[:cool:] => <img src="https://dv.netllama.us/dv/images/smilies/cool.png" alt
 ="Cool" title="Cool" class="smilie smilie_3" />,[:D] => <img src="https://dv.netllama.us/dv/images/smilies/biggrin.png" alt="Big Grin" title="Big Grin" class="smilie smilie_4" />,[:P] => <img src="https://dv.netllama.us/dv/images/smilies/tongue.png" alt="Tongue" title="Tongue" class="smilie smilie_5" />,[:rolleyes:] => <img src="https://dv.netllama.us/dv/images/smilies/rolleyes.png" alt="Rolleyes" title="Rolleyes" class="smilie smilie_6" />,[:shy:] => <img src="https://dv.netllama.us/dv/images/smilies/shy.png" alt="Shy" title="Shy" class="smilie smilie_7" />,[:(] => <img src="https://dv.netllama.us/dv/images/smilies/sad.png" alt="Sad" title="Sad" class="smilie smilie_8" />,[:at:] => <img src="https://dv.netllama.us/dv/images/smilies/at.png" alt="At" title="At" class="smilie smilie_9" />,[:angel:] => <img src="https://dv.netllama.us/dv/images/smilies/angel.png" alt="Angel" title="Angel" class="smilie smilie_10" />,[:@] => <img src="https://dv.netllama.us/dv/images/smilies/angry.png"
 alt="Angry" title="Angry" class="smilie smilie_11"

The infamous Death Valley Jim commented on his planned unauthorized fifteen-minute heli-tours of the "green and red zone." "This Badwater Basin Bargain of $1,500 per person is of course a fly-by-night operation." 

[CENSORED]) called at [/var/www/html/dv/inc/class_parser.php:513]
#6  postParser->parse_mycode(CNN (Cactus News Network) Furnace Creek, CA - The new phenomenon of green and red colored salt flat bioluminescent bulges has replaced the Racetrack Playa Sailing Stones mystery in Death Valley. National Park Rangers and Scientists are baffled at how gullible visitors are flocking to the Badwater Basin due to this bio-geological fake news. 

The infamous Death Valley Jim commented on his planned unauthorized fifteen-minute heli-tours of the "green and red zone." "This Badwater Basin Bargain of $1,500 per person is of course a fly-by-night operation." 

[CENSORED]) called at [/var/www/html/dv/inc/class_parser.php:228]
#7  postParser->parse_message(CNN (Cactus News Network) Furnace Creek, CA - The new phenomenon of green and red colored salt flat bioluminescent bulges has replaced the Racetrack Playa Sailing Stones mystery in Death Valley. National Park Rangers and Scientists are baffled at how gullible visitors are flocking to the Badwater Basin due to this bio-geological fake news. 

The infamous Death Valley Jim commented on his planned unauthorized fifteen-minute heli-tours of the "green and red zone." "This Badwater Basin Bargain of $1,500 per person is of course a fly-by-night operation." 

[CENSORED], Array ([allow_html] => 0,[allow_mycode] => 1,[allow_smilies] => 1,[allow_imgcode] => 1,[allow_videocode] => 1,[filter_badwords] => 1,[me_username] => DeathValleyDazed)) called at [/var/www/html/dv/inc/functions_post.php:817]
#8  build_postbit(Array ([uid] => 32,[username] => DeathValleyDazed,[password] => 6e6e3c4bfd279bd4e2e05f9c7dc68d8b,[salt] => Xo8RMGdh,[loginkey] => dNKlZIo7O7bE1RMrD6pZda4EuxOYYdtzc0CDDNxLsu2oelolLt,[email] => [email protected],[postnum] => 447,[threadnum] => 133,[avatar] => ./uploads/avatars/avatar_32.png?dateline=1600547471,[avatardimensions] => 100|91,[avatartype] => upload,[usergroup] => 2,[additionalgroups] => ,[displaygroup] => 2,[usertitle] => Senior Member,[regdate] => 1600380718,[lastactive] => 1671298584,[lastvisit] => 1671150611,[lastpost] => 1671298582,[website] => ,[icq] => 0,[skype] => ,[google] => ,[birthday] => ,[birthdayprivacy] => all,[signature] => Life begins in Death Valley ,[allownotices] => 1,[hideemail] => 0,[subscriptionmethod] => 2,[invisible] => 0,[receivepms] => 1,[receivefrombuddy] => 0,[pmnotice] => 1,[pmnotify] => 1,[buddyrequestspm] => 1,[buddyrequestsauto] => 0,[threadmode] => ,[showimages] => 1,[showvideos] => 1,[showsigs] => 1,[showavatars]
 => 1,[showquickreply] => 1,[showredirect] => 1,[ppp] => 0,[tpp] => 0,[daysprune] => 0,[dateformat] => ,[timeformat] => ,[timezone] => -6,[dst] => 1,[dstcorrection] => 2,[buddylist] => ,[ignorelist] => ,[style] => 0,[away] => 0,[awaydate] => 0,[returndate] => 0,[awayreason] => ,[pmfolders] => 0**$%%$1**$%%$2**$%%$3**$%%$4**,[notepad] => ,[referrer] => 0,[referrals] => 0,[reputation] => 0,[regip] => \xcf87f22e,[lastip] => \xcf87f21d,[language] => ,[timeonline] => 333435,[showcodebuttons] => 1,[totalpms] => 96,[unreadpms] => 0,[warningpoints] => 0,[moderateposts] => 0,[moderationtime] => 0,[suspendposting] => 0,[suspensiontime] => 0,[suspendsignature] => 0,[suspendsigtime] => 0,[coppauser] => 0,[classicpostbit] => 0,[loginattempts] => 4,[loginlockoutexpiry] => 1671924890,[usernotes] => ,[sourceeditor] => 0,[privacy_policy_last_read] => 1601086477,[personal_data_erasure_pending] => 0,[userusername] => DeathValleyDazed,[pid] => 79800,[tid] => 25992,[replyto] => 0,[fid] => 3,[subject] =>
 Bioluminescent Bulges - Death Valley Basin - Dec 2021,[icon] => 0,[dateline] => 1642030616,[message] => CNN (Cactus News Network) Furnace Creek, CA - The new phenomenon of green and red colored salt flat bioluminescent bulges has replaced the Racetrack Playa Sailing Stones mystery in Death Valley. National Park Rangers and Scientists are baffled at how gullible visitors are flocking to the Badwater Basin due to this bio-geological fake news. 

The infamous Death Valley Jim commented on his planned unauthorized fifteen-minute heli-tours of the "green and red zone." "This Badwater Basin Bargain of $1,500 per person is of course a fly-by-night operation." 

[CENSORED],[ipaddress] => \xcf87f27e,[includesig] => 1,[smilieoff] => 0,[edituid] => 0,[edittime] => 0,[editreason] => ,[visible] => 1,[editcount] => 0,[ufid] => 32,[fid1] => ,[fid2] => ,[fid3] => ,[reporters] => ,[editusername] => ,[aid] => ,[pmid] => ,[posturl] => <!-- start: postbit_posturl -->
<div class="float_right" style="vertical-align: top">
<strong><a href="thread-25992-post-79800.html#pid79800" title="Bioluminescent Bulges - Death Valley Basin - Dec 2021">#1</a></strong>

</div>
<!-- end: postbit_posturl -->,[button_multiquote] => ,[subject_extra] => ,[attachments] => ,[button_rep] => ,[button_warn] => ,[button_purgespammer] => ,[button_pm] => ,[button_reply_pm] => ,[button_replyall_pm] => ,[button_forward_pm] => ,[button_delete_pm] => ,[replink] => ,[warninglevel] => ,[postdate] => 2022-01-12, 05:36 PM,[author] => 32,[subject_title] => Bioluminescent Bulges - Death Valley Basin - Dec 2021,[groupimage] => ,[profilelink_plain] => user-32.html,[username_formatted] => DeathValleyDazed,[profilelink] => <a href="https://dv.netllama.us/dv/user-32.html">DeathValleyDazed</a>,[stars] => 4,[starimage] => images/star.png,[userstars] => <img src="images/star.png" border="0" alt="*" /><img src="images/star.png" border="0" alt="*" /><img src="images/star.png" border="0" alt="*" /><img src="images/star.png" border="0" alt="*" /><br />,[onlinestatus] => <!-- start: postbit_offline -->
<img src="https://dv.netllama.us/dv/images/buddy_offline.png" title="Offline" alt="Offline" class="buddy_status" />
<!-- end: postbit_offline -->,[useravatar] => <!-- start: postbit_avatar -->
<div class="author_avatar"><a href="user-32.html"><img src="https://dv.netllama.us/dv/uploads/avatars/avatar_32.png?dateline=1600547471" alt="" width="55" height="51" /></a></div>
<!-- end: postbit_avatar -->,[button_find] => <!-- start: postbit_find -->
<a href="search.php?action=finduser&amp;uid=32" title="Find all posts by this user" class="postbit_find"><span>Find</span></a>
<!-- end: postbit_find -->,[button_www] => ,[button_email] => ,[userregdate] => Sep 2020,[profilefield] => ,[user_details] => <!-- start: postbit_author_user -->

        Posts: 447<br />
        Threads: 133<br />
        Joined: Sep 2020

<!-- end: postbit_author_user -->,[input_editreason] => ,[button_edit] => ,[button_quickdelete] => ,[button_quickrestore] => ,[button_quote] => <!-- start: postbit_quote -->
<a href="newreply.php?tid=25992&amp;replyto=79800" title="Quote this message in a reply" class="postbit_quote postbit_mirage"><span>Reply</span></a>
<!-- end: postbit_quote -->,[button_quickquote] => ,[button_report] => ,[editedmsg] => ,[inlinecheck] => ,[postlink] => thread-25992-post-79800.html,[iplogged] => ,[poststatus] => )) called at [/var/www/html/dv/showthread.php:1119]


The other undefined references have a very similar error spew, with just some minor differences:

Type: 2
File: inc/class_parser.php (Line no. 1591)
Message
Undefined array key "v"
Back Trace: #0  errorHandler->email_error(2, Undefined array key "v", inc/class_parser.php, 1591) called at [/var/www/html/dv/inc/class_error.php:229]
#1  errorHandler->error(2, Undefined array key "v", inc/class_parser.php, 1591) called at [/var/www/html/dv/inc/class_error.php:153]
#2  errorHandler->error_callback(2, Undefined array key "v", /var/www/html/dv/inc/class_parser.php, 1591) called at [/var/www/html/dv/inc/class_parser.php:1591]


Type: 2
File: inc/class_parser.php (Line no. 1505)
Message
Undefined array key "query"
Back Trace: #0  errorHandler->email_error(2, Undefined array key "query", inc/class_parser.php, 1505) called at [/var/www/html/dv/inc/class_error.php:229]
#1  errorHandler->error(2, Undefined array key "query", inc/class_parser.php, 1505) called at [/var/www/html/dv/inc/class_error.php:153]
#2  errorHandler->error_callback(2, Undefined array key "query", /var/www/html/dv/inc/class_parser.php, 1505) called at [/var/www/html/dv/inc/class_parser.php:1505]


Type: 2
File: inc/class_parser.php (Line no. 1587)
Message
Undefined array key 0
Back Trace: #0  errorHandler->email_error(2, Undefined array key 0, inc/class_parser.php, 1587) called at [/var/www/html/dv/inc/class_error.php:229]
#1  errorHandler->error(2, Undefined array key 0, inc/class_parser.php, 1587) called at [/var/www/html/dv/inc/class_error.php:153]
#2  errorHandler->error_callback(2, Undefined array key 0, /var/www/html/dv/inc/class_parser.php, 1587) called at [/var/www/html/dv/inc/class_parser.php:1587]
#3  postParser->mycode_parse_video(youtube, https://youtu.be/mBy6wHPeHbE) called at [/var/www/html/dv/inc/class_parser.php:1640]
#4  postParser->mycode_parse_video_callback(Array ([0] => [CENSORED],[1] => youtube,[2] => https://youtu.be/mBy6wHPeHbE))

Type: 2
File: inc/class_parser.php (Line no. 1510)
Message
Undefined array key 1
Back Trace: #0  errorHandler->email_error(2, Undefined array key 1, inc/class_parser.php, 1510) called at [/var/www/html/dv/inc/class_error.php:229]
#1  errorHandler->error(2, Undefined array key 1, inc/class_parser.php, 1510) called at [/var/www/html/dv/inc/class_error.php:153]
#2  errorHandler->error_callback(2, Undefined array key 1, /var/www/html/dv/inc/class_parser.php, 1510) called at [/var/www/html/dv/inc/class_parser.php:1510]
#3  postParser->mycode_parse_video(youtube, https://youtu.be/mBy6wHPeHbE) called at [/var/www/html/dv/inc/class_parser.php:1640]



This problem definitely did not exist prior to the php upgrade, and goes away if I downgrade. I'd appreciate any and all suggestions how to mitigate this issue, as its filling up logs whenever anyone (humans, bots, etc) view this particular thread (  https://dv.netllama.us/dv/thread-25992.html ).

EDIT: I had to censor out the youtube links or I could submit this post, as this forum is misdetecting them as actual videos, which are apparently limited to 1 per message. 

thanks
I'm running 1.8.33 in a Linux environment.  Since 1.8.33 included php-8 fixes, I figured I'd attempt to update from php-7 to php8 again.  Sadly, I'm seeing lots of new errors:

Type: 2
File: search.php (Line no. 476)
Message
Undefined array key "lastread"
Back Trace: #0  errorHandler->email_error(2, Undefined array key "lastread", search.php, 476) called at [/var/www/html/dv/inc/class_error.php:229]
#1  errorHandler->error(2, Undefined array key "lastread", search.php, 476) called at [/var/www/html/dv/inc/class_error.php:153]
#2  errorHandler->error_callback(2, Undefined array key "lastread", /var/www/html/dv/search.php, 476) called at [/var/www/html/dv/search.php:476]

Type: 2
File: showthread.php(1617) : eval()'d code (Line no. 60)
Message
Undefined variable $search_thread
Back Trace: #0  errorHandler->email_error(2, Undefined variable $search_thread, showthread.php(1617) : eval()'d code, 60) called at [/var/www/html/dv/inc/class_error.php:229]
#1  errorHandler->error(2, Undefined variable $search_thread, showthread.php(1617) : eval()'d code, 60) called at [/var/www/html/dv/inc/class_error.php:153]
#2  errorHandler->error_callback(2, Undefined variable $search_thread, /var/www/html/dv/showthread.php(1617) : eval()'d code, 60) called at [/var/www/html/dv/showthread.php(1617) : eval()'d code:60]
#3  eval() called at [/var/www/html/dv/showthread.php:1617]

If I downgrade back to php7, all of the errors go away.

Any suggestions?
Still seeing this mess with 1.8.33 & php8, and would appreciate some help.
Try the attached modified files by replacing the old ones.

[attachment=45694]

[attachment=45695]
I'm running 1.8.33 on a Linux server. Whenever I attempt to upgrade from php7 to php8, I start getting flooded with these errors from functions_search.php:

Type: 2
File: inc/functions_search.php (Line no. 1166)
Message
Undefined array key "author"
Back Trace: 
#0  errorHandler->email_error(2, Undefined array key "author", inc/functions_search.php, 1166) called at [/var/www/html/dv-test0/inc/class_error.php:229]
#1  errorHandler->error(2, Undefined array key "author", inc/functions_search.php, 1166) called at [/var/www/html/dv-test0/inc/class_error.php:153]
#2  errorHandler->error_callback(2, Undefined array key "author", /var/www/html/dv-test0/inc/functions_search.php, 1166) called at [/var/www/html/dv-test0/inc/functions_search.php:1166]
#3  perform_search_mysql(Array ([keywords] => outback,[postthread] => 1,[tid] => 25895)) called at [/var/www/html/dv-test0/search.php:1719]

Type: 2
File: inc/functions_search.php (Line no. 1209)
Message
Undefined array key "postdate"
Back Trace: 
#0  errorHandler->email_error(2, Undefined array key "postdate", inc/functions_search.php, 1209) called at [/var/www/html/dv-test0/inc/class_error.php:229]
#1  errorHandler->error(2, Undefined array key "postdate", inc/functions_search.php, 1209) called at [/var/www/html/dv-test0/inc/class_error.php:153]
#2  errorHandler->error_callback(2, Undefined array key "postdate", /var/www/html/dv-test0/inc/functions_search.php, 1209) called at [/var/www/html/dv-test0/inc/functions_search.php:1209]
#3  perform_search_mysql(Array ([keywords] => outback,[postthread] => 1,[tid] => 25895)) called at [/var/www/html/dv-test0/search.php:1719]

Type: 2
File: inc/functions_search.php (Line no. 1227)
Message
Undefined array key "numreplies"
Back Trace: 
#0  errorHandler->email_error(2, Undefined array key "numreplies", inc/functions_search.php, 1227) called at [/var/www/html/dv-test0/inc/class_error.php:229]
#1  errorHandler->error(2, Undefined array key "numreplies", inc/functions_search.php, 1227) called at [/var/www/html/dv-test0/inc/class_error.php:153]
#2  errorHandler->error_callback(2, Undefined array key "numreplies", /var/www/html/dv-test0/inc/functions_search.php, 1227) called at [/var/www/html/dv-test0/inc/functions_search.php:1227]
#3  perform_search_mysql(Array ([keywords] => outback,[postthread] => 1,[tid] => 25895)) called at [/var/www/html/dv-test0/search.php:1719]

Type: 2
File: inc/functions_search.php (Line no. 1241)
Message
Undefined array key "threadprefix"
Back Trace: 
#0  errorHandler->email_error(2, Undefined array key "threadprefix", inc/functions_search.php, 1241) called at [/var/www/html/dv-test0/inc/class_error.php:229]
#1  errorHandler->error(2, Undefined array key "threadprefix", inc/functions_search.php, 1241) called at [/var/www/html/dv-test0/inc/class_error.php:153]
#2  errorHandler->error_callback(2, Undefined array key "threadprefix", /var/www/html/dv-test0/inc/functions_search.php, 1241) called at [/var/www/html/dv-test0/inc/functions_search.php:1241]
#3  perform_search_mysql(Array ([keywords] => outback,[postthread] => 1,[tid] => 25895)) called at [/var/www/html/dv-test0/search.php:1719]

This only happens with php8.  Help please?
@SvePu thank you, those changes fixed the errors above with php8.

If you have any time to look at my other php8 upgrade threads, I'd greatly appreciate it:

https://community.mybb.com/thread-237263.html

https://community.mybb.com/thread-237376.html
Try the attached file and copy it to ROOT/inc/functions_search.php (replace existing one).
[attachment=45699]
A lot of issues will be fixed here => https://github.com/mybb/mybb/pull/4613/f...71e7df0dcd
Thanks for the fast reply!  I'm seeing this error with your new version of functions_search.php:

Type: 2
File: inc/functions_search.php (Line no. 1241)
Message
Undefined array key 0
Back Trace: 
#0  errorHandler->email_error(2, Undefined array key 0, inc/functions_search.php, 1241) called at [/var/www/html/dv-test0/inc/class_error.php:229]
#1  errorHandler->error(2, Undefined array key 0, inc/functions_search.php, 1241) called at [/var/www/html/dv-test0/inc/class_error.php:153]
#2  errorHandler->error_callback(2, Undefined array key 0, /var/www/html/dv-test0/inc/functions_search.php, 1241) called at [/var/www/html/dv-test0/inc/functions_search.php:1241]
#3  perform_search_mysql(Array ([keywords] => death,[author] => ,[postthread] => 1,[matchusername] => 0,[postdate] => 0,[pddir] => 0,[forums] => Array ([0] => ),[findthreadst] => 0,[numreplies] => 0,[threadprefix] => Array ())) called at [/var/www/html/dv-test0/search.php:1603]
I've merged your 3 threads together as they're broadly the same issue.
Pages: 1 2