From cfac99be4e7f93c4042cb59d56b7ea84dc6bbeae Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Fri, 7 Jan 2022 16:21:49 -0500 Subject: [PATCH] better debugging when the row has no Id --- web/includes/Object.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/web/includes/Object.php b/web/includes/Object.php index 1a9011586..ff5d40baa 100644 --- a/web/includes/Object.php +++ b/web/includes/Object.php @@ -11,19 +11,24 @@ class ZM_Object { $class = get_class($this); $row = NULL; - if ( $IdOrRow ) { + if ($IdOrRow) { - if ( is_integer($IdOrRow) or ctype_digit($IdOrRow) ) { + if (is_integer($IdOrRow) or ctype_digit($IdOrRow)) { $table = $class::$table; $row = dbFetchOne("SELECT * FROM `$table` WHERE `Id`=?", NULL, array($IdOrRow)); - if ( !$row ) { + if (!$row) { Error("Unable to load $class record for Id=$IdOrRow"); + return; } - } else if ( is_array($IdOrRow) ) { + } else if (is_array($IdOrRow)) { $row = $IdOrRow; } if ( $row ) { + if (!isset($row['Id'])) { + Error("No Id in " . print_r($row, true)); + return; + } foreach ($row as $k => $v) { $this->{$k} = $v; }