Ensure we set workers to 0

If no workers are found false is returned. Smarty is not able to set a
default on `false` values so we have to set it to 0 if the query failed.

Fixes #418
This commit is contained in:
Sebastian Grewe 2013-07-11 11:43:48 +02:00
parent 39d1193e6a
commit 1344f39f96
2 changed files with 3 additions and 9 deletions

View File

@ -135,15 +135,9 @@ class Worker {
**/
public function getCountAllActiveWorkers() {
$this->debug->append("STA " . __METHOD__, 4);
$stmt = $this->mysqli->prepare("SELECT COUNT(DISTINCT username) AS total FROM " . $this->share->getTableName() . " WHERE time > DATE_SUB(now(), INTERVAL 10 MINUTE)");
if ($this->checkStmt($stmt)) {
if (!$stmt->execute()) {
return false;
}
$result = $stmt->get_result();
$stmt->close();
$stmt = $this->mysqli->prepare("SELECT IFNULL(COUNT(DISTINCT username), 0) AS total FROM " . $this->share->getTableName() . " WHERE time > DATE_SUB(now(), INTERVAL 10 MINUTE)");
if ($this->checkStmt($stmt) && $stmt->execute() && $result = $stmt->get_result())
return $result->fetch_object()->total;
}
return false;
}

View File

@ -24,7 +24,7 @@ if (@$_SESSION['AUTHENTICATED']) {
$bitcoin->can_connect() === true ? $dNetworkHashrate = $bitcoin->query('getnetworkhashps') : $dNetworkHashrate = 0;
// Fetch some data
$iCurrentActiveWorkers = $worker->getCountAllActiveWorkers();
if (!$iCurrentActiveWorkers = $worker->getCountAllActiveWorkers()) $iCurrentActiveWorkers = 0;
$iCurrentPoolHashrate = $statistics->getCurrentHashrate();
$iCurrentPoolShareRate = $statistics->getCurrentShareRate();