From: Kevin Day Date: Sat, 3 Feb 2018 18:39:13 +0000 (-0600) Subject: Bugfix: inconsistency in c_base_error's s_false() and s_true() NULL value handling X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=dc434d9e9652a94537887a865f4bfb07d05cf4a0;p=koopa Bugfix: inconsistency in c_base_error's s_false() and s_true() NULL value handling The comments designate that when NULL is specified, no error should be assigned. The previous behavior was instead creating a new, empty error. The error classes also seem to accept NULL values, which will create an empty error array (clearing existing values). By passing NULL instead of creating an error object makes the behavior consistent with other code. --- diff --git a/common/base/classes/base_return.php b/common/base/classes/base_return.php index 6008dfa..2ea386f 100644 --- a/common/base/classes/base_return.php +++ b/common/base/classes/base_return.php @@ -1810,9 +1810,7 @@ class c_base_return_error { $object_return = new c_base_return_true(); if (is_null($error)) { - $object_error = new c_base_error(); - $object_return->set_error($object_error); - unset($object_error); + $object_return->set_error(NULL); } elseif (is_array($error)) { foreach ($error as $delta => $value) { @@ -1843,9 +1841,7 @@ class c_base_return_error { $object_return = new c_base_return_false(); if (is_null($error)) { - $object_error = new c_base_error(); - $object_return->set_error($object_error); - unset($object_error); + $object_return->set_error(null); } elseif (is_array($error)) { foreach ($error as $delta => $value) {