From 5ee015873513dd929c797d6f0057738d05839ed8 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Fri, 10 Jan 2020 16:42:41 -0500 Subject: [PATCH] Set defaults for vars == '' --- web/includes/Object.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/web/includes/Object.php b/web/includes/Object.php index 9f29aed88..bf647c230 100644 --- a/web/includes/Object.php +++ b/web/includes/Object.php @@ -291,11 +291,13 @@ Logger::Debug("$k => Have default for $v: "); $this->set($new_values); } + # Set defaults. Note that we only replace "" with null, not other values + # because for example if we want to clear TimestampFormat, we clear it, but the default is a string value foreach ( $this->defaults as $field => $default ) { - if ( (!array_key_exists($field, $this)) or empty($this->{$field}) ) { + if ( (!array_key_exists($field, $this)) or ($this->{$field} == '') ) { if ( is_array($default) ) { $this->{$field} = $default['default']; - } else { + } else if ( $default == null ) { $this->{$field} = $default; } }