Skip to main content
Recent Posts
91
Support / Re: Error message "Undefined variable: key" for the Profile.subs.php
Last post by Spuds -
Looks like a small bug in the custom profile fields area, probably pretty old as well.  PHP8 is less forgiving which is a good thing really.

I'm not at a place where I can do any testing, but you can try the following to prevent the warning.
Code: (find) [Select]
			{ 
$replacements['{KEY}'] = $row['col_name'] . '_' . $key;
}
with
Code: (replace) [Select]
			{
$key = $key ?? 0;
$replacements['{KEY}'] = $row['col_name'] . '_' . $key;
}
97
Support / Error message "Undefined variable: key" for the Profile.subs.php
Last post by Mrs. Chaos -
Hi,
When I try to access a user's profile, the message "Undefined variable: key" now appears. What's wrong there?
This is displayed in the error log:

Type of error: Undefined
Notice: Undefined variable: key
https://forum.xxx.de/index.php?action=profile

File: /www/htdocs/xxx/xxx/sources/subs/Profile.subs.php
Line: 293

Code: [Select]
291		if (in_array($row['field_type'], array('radio', 'select')))
292 {
293 $replacements['{KEY}'] = $row['col_name'] . '_' . $key;
294 }
295 $output_html = strtr($row['enclose'], $replacements);


Maybe the error has to do with this error message for the addon "Stop Spammer":

Type of error: Undefined
Notice: Undefined index: stopspammer_profilecheck
https://forum.xxx.de/index.php?action=profile

File: /www/htdocs/xxx/xxx/sources/addons/StopSpammer/StopSpammer_hooks.php
Line: 465

Code: [Select]
457	   // Add "Check this member" under "Action" menu in individual profile view
458    public static function profile_areas(&$profile_areas)
459    {
460    global $txt, $scripturl, $memID, $modSettings;
461    loadLanguage('StopSpammer');
462
463    $profile_areas['profile_action']['areas'] = elk_array_insert($profile_areas['profile_action']['areas'], 'activateaccount', array(
464       'checkmember' => array(
465      'label' => $txt['stopspammer_profilecheck'],
466    'custom_url' => $scripturl . '?action=admin;area=viewmembers;sa=query;params=' . base64_encode(serialize(array('mem_id' => $memID, 'types' => array('mem_id' => '=')))),
467    'enabled' => !empty($modSettings['stopspammer_enable']),
468    'sc' => 'get',
469    'permission' => array(
470    'own' => array('profile_remove_any', 'profile_remove_own'),
471    'any' => array('profile_remove_any', 'moderate_forum'),
472    ),
473    )), 'after');
474    }
99
Support / Re: Error in the Server.subs.php
Last post by Arantor -
sys_getloadavg() is for some reason returning false rather than an array - but I’m not on my desktop to look at the rest of it to see how safely to change it.

Maybe it should be
Code: [Select]
// The internal function should always be available
if (function_exists('sys_getloadavg'))
{
$sys_load = sys_getloadavg();

if (is_array($sys_load))
return $sys_load[0] / $cores;
}

Not 100% sure if the indentation is perfect, tabs on iPad are hard! But if it’s not an array it shouldn’t be using that method to return.
100
Support / Error in the Server.subs.php
Last post by Mrs. Chaos -
Hello,
I keep getting the same three error messages. This is the case in my main forum and also in the test forum. I completely reinstalled the test forum yesterday, but one of the errors is already reported there.
It appears when I click on the admin button in the menu after logging in and also when I click on "Administration Center" in the menu on mouseover over the admin button.
That's the error message, what's wrong there in the code?

Type of error: General
Warning: Trying to access array offset on value of type bool
https://forum.xxx.de/index.php?action=admin;area=index;ac04180f1=c04180f1ed64deOM6BNBrU3bu8i6WRKm
File: /www/htdocs/xxx/xxx/sources/subs/Server.subs.php
Line: 34

Code: [Select]
30	// The internal function should always be available
31 if (function_exists('sys_getloadavg'))
32 {
33 $sys_load = sys_getloadavg();
34 return $sys_load[0] / $cores;
35 }

Regards
Mrs. Chaos