Skip to content

Commit 112a5da

Browse files
fix: match single-server ServerId=0 in Server::ReadStats
0680195 bound $this->Id() directly in the stats lookup. On a single-server install the Server object's Id() is empty/undef and zmstats.pl writes the rows under ServerId=0 (ZM_SERVER_ID ? ZM_SERVER_ID : 0), so the query matched nothing and CpuLoad/load reported as -1. Coerce a falsy id to 0 so the reader mirrors the writer; a real (multi-server) id still passes through unchanged. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
1 parent 819a211 commit 112a5da

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

web/includes/Server.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,10 @@ class Server extends ZM_Object {
4646

4747
public function ReadStats() {
4848
#ToDo: Analyze the date of the last entry, because The entry may be out of date and not updated.
49-
$dbStats = dbFetchAll('SELECT * FROM Server_Stats WHERE ServerId=? ORDER BY TimeStamp DESC LIMIT 1',NULL, [$this->Id()]);
49+
# Single-server installs store stats under ServerId=0 (zmstats.pl writes
50+
# ZM_SERVER_ID ? ZM_SERVER_ID : 0), and $this->Id() is empty/undef there.
51+
# Coerce a falsy id to 0 so the lookup matches; a real id passes through.
52+
$dbStats = dbFetchAll('SELECT * FROM Server_Stats WHERE ServerId=? ORDER BY TimeStamp DESC LIMIT 1',NULL, [$this->Id() ? $this->Id() : 0]);
5053
if (count($dbStats)) {
5154
$this->TimeUpdateStats = $dbStats[0]['TimeStamp'];
5255
$this->CpuLoad = $dbStats[0]['CpuLoad'];

0 commit comments

Comments
 (0)