2023-02-03, 02:57 AM
(2023-02-01, 11:04 AM)HLFadmin Wrote: Thanks for the update. It works without problem on live forum still running PHP 7.4, also no errors on test forum on PHP 8, until I get this one.
Warning [2] Undefined variable $cnv_unread_convmsgs - Line: 1276 - File: inc/plugins/converse.php PHP 8.0.27 (Linux)
$mybb->user['cnv_unread_msg_str'] = $cnv_unread_convmsgs;
This happens when not logged in. My forum requires a log in.
Oops. I thought I'd handled that scenario. Apparently not. Am temporarily without access to my main machine, but will examine the code when I'm back to it.
(2023-02-01, 11:04 AM)HLFadmin Wrote: I believe I fixed it by adding a line at 1248 to define it.
$cnv_unread_convmsgs = '';
Is it that simple? Define a variable? That variable only appears within the function, so definition stays within the function.
Without looking at the code to refresh my memory, that *does* seem like a plausible fix. It's the usual fix for that warning message - to make sure that the variable is defined when it's used. The alternative approach is to first *check*, using either
isset()
or !empty()
, that (whether) it's defined before using it.