[4/5] Fix warning with invalid time zone

Message ID 20170227184955.25495-4-lfleischer@archlinux.org
State Accepted, archived
Headers show
Series [1/5] 404.php: Squelch warning on empty PATH_INFO | expand

Commit Message

Lukas Fleischer Feb. 27, 2017, 6:49 p.m. UTC
The SQL query retrieving the time zone from the database may return an
empty result set if the session timeout was reached. Handle such cases
gracefully by leaving the timezone variable unset.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
---
 web/lib/timezone.inc.php | 3 +++
 1 file changed, 3 insertions(+)

Patch

diff --git a/web/lib/timezone.inc.php b/web/lib/timezone.inc.php
index 9fb2433..949f846 100644
--- a/web/lib/timezone.inc.php
+++ b/web/lib/timezone.inc.php
@@ -42,6 +42,9 @@  function set_tz() {
 
 		if ($result) {
 			$timezone = $result->fetchColumn(0);
+			if (!$timezone) {
+				unset($timezone);
+			}
 		}
 
 		$update_cookie = true;