diff options
author | Malf Furious <m@lfurio.us> | 2018-09-20 00:09:08 -0400 |
---|---|---|
committer | Malf Furious <m@lfurio.us> | 2018-09-20 00:09:08 -0400 |
commit | 1daec62c0ab6590d3a30464b2f679baea3ca3936 (patch) | |
tree | 117aedc72e9944140ae2d8545135e860ad184a88 /app/class | |
parent | 5c6ca9e4cf6d26f72c3f6d4ec86bb703aae1ea73 (diff) | |
download | scrott-1daec62c0ab6590d3a30464b2f679baea3ca3936.tar.gz scrott-1daec62c0ab6590d3a30464b2f679baea3ca3936.zip |
table: Fix bug in constructor
This particular flaw was dampening (and could popentially be hiding) the
effects of other bugs.
For instance, in this case, a GUID of "" was invalidly being used to
construct an object. This should obviously be considered an error, but
since "" evaluates to false, the construction was treated as default (no
GUID) construction and succedded. It wasn't until later when missing
properties were accessed that random PHP error messages clued me into what
was happening.
Now, when any sort of explicit value is used to construct an object (not
NULL), an object load will be attempted, giving bad input more chances
to fail outright and trigger an exception. In addition, the 'no such
guid' exception message is updated to place quotes ('') around the GUID
string to make it more obvious when "" is used in the future.
Diffstat (limited to 'app/class')
-rw-r--r-- | app/class/table.class.php | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/app/class/table.class.php b/app/class/table.class.php index 5e4c823..618d938 100644 --- a/app/class/table.class.php +++ b/app/class/table.class.php @@ -37,7 +37,7 @@ abstract class table */ public function __construct(?string $guid = NULL) { - if ($guid) + if ($guid !== NULL) $this->loadObj($guid); } @@ -51,7 +51,7 @@ abstract class table $guid = database::esc($guid); if (!self::isGUID($guid)) - throw new Exception("GUID " . $guid . " does not exist"); + throw new Exception("GUID '" . $guid . "' does not exist"); foreach ($this->fields as $tbl => $flds) { |