Skip to main content
Topic: Error in the Server.subs.php (Read 890 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Error in the Server.subs.php

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
ElkArte version: 1.1.8 / Theme: BeSocial / PHP 8.0

Re: Error in the Server.subs.php

Reply #1

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.

Re: Error in the Server.subs.php

Reply #2

Thank you, that helped!
In both forums, the error messages now stay away. :)
ElkArte version: 1.1.8 / Theme: BeSocial / PHP 8.0

Re: Error in the Server.subs.php

Reply #3

Interesting it is returning a bool.  I'll add this to the 1.1.9 tracker

 

Re: Error in the Server.subs.php

Reply #4

sys_getloadavg() does say in the manual it can return false. But it never explains why it would return false, merely 'on failure' and 'this isn't implemented on Windows' (not that the OP has a Windows setup)

SMF originally used a combination of querying /proc/loadavg and calling uptime on the command line to identify this.

Re: Error in the Server.subs.php

Reply #5

Well would you look at that, it indeed says array|false  :-[