From 4f2402e6ed85e874d7e5876b340bb81e0d1ac270 Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Wed, 3 Jul 2013 08:09:09 +0200 Subject: [PATCH] Fix PHP warning in notification class * Fix PHP Warning if no notification settings exist yet Fixes #346 --- public/include/classes/notification.class.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/public/include/classes/notification.class.php b/public/include/classes/notification.class.php index e07b3c32..910f5674 100644 --- a/public/include/classes/notification.class.php +++ b/public/include/classes/notification.class.php @@ -99,12 +99,16 @@ class Notification extends Mail { $this->debug->append("STA " . __METHOD__, 4); $stmt = $this->mysqli->prepare("SELECT * FROM $this->tableSettings WHERE account_id = ?"); if ($stmt && $stmt->bind_param('i', $account_id) && $stmt->execute() && $result = $stmt->get_result()) { - while ($row = $result->fetch_assoc()) { - $aData[$row['type']] = $row['active']; + if ($result->num_rows > 0) { + while ($row = $result->fetch_assoc()) { + $aData[$row['type']] = $row['active']; + } + return $aData; } - return $aData; } // Catchall + $this->setErrorMessage('Unable to fetch notification settings'); + $this->debug->append('Failed fetching notification settings for ' . $account_id . ': ' . $this->mysqli->error); return false; }