From 575d532b06eeae5eac77f231265e8fd7034d4fd7 Mon Sep 17 00:00:00 2001 From: Malf Furious Date: Fri, 7 Sep 2018 07:02:18 -0400 Subject: Fix bug in function table->loadObj() If a table query yeilds zero rows, we would still attempt to load the first (index zero) into $this, causing an error to be thrown by PHP. We are now checking the size of the results array first. --- app/class/table.class.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'app/class') diff --git a/app/class/table.class.php b/app/class/table.class.php index 52a3e7d..28308bb 100644 --- a/app/class/table.class.php +++ b/app/class/table.class.php @@ -57,7 +57,13 @@ abstract class table { $tbl = database::esc($tbl); $query = "SELECT * FROM " . $tbl . " WHERE guid = '" . $guid . "'"; - $res = database::query($query)[0]; + $res = database::query($query); + + /* no results */ + if (count($res) == 0) + continue; + + $res = $res[0]; foreach ($flds as $fld) { -- cgit v1.2.3