From 31b2326e1e9452f0d47d5dfe75db0b0bbb825f1f Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Fri, 13 Jul 2018 10:56:51 +0200 Subject: [PATCH] DbObjectWithSettings: fix for unstored objects --- library/Director/Data/Db/DbObjectWithSettings.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/library/Director/Data/Db/DbObjectWithSettings.php b/library/Director/Data/Db/DbObjectWithSettings.php index 5c1f22ed..a45082f5 100644 --- a/library/Director/Data/Db/DbObjectWithSettings.php +++ b/library/Director/Data/Db/DbObjectWithSettings.php @@ -139,10 +139,15 @@ abstract class DbObjectWithSettings extends DbObject protected function fetchSettingsFromDb() { $db = $this->getDb(); + $id = $this->get('id'); + if (! $id) { + return []; + } + return $db->fetchPairs( $db->select() ->from($this->settingsTable, ['setting_name', 'setting_value']) - ->where($this->settingsRemoteId . ' = ?', $this->get('id')) + ->where($this->settingsRemoteId . ' = ?', $id) ->order('setting_name') ); }