From dc434d9e9652a94537887a865f4bfb07d05cf4a0 Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Sat, 3 Feb 2018 12:39:13 -0600 Subject: [PATCH] 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. --- common/base/classes/base_return.php | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) 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) { -- 1.8.3.1