From c5e0a709ad26f164ca1ea07361e4775b312e9a4a Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Fri, 31 Jul 2015 16:00:04 +0200 Subject: [PATCH] DirectorDatafield: fix unset/delete operation --- library/Director/Objects/DirectorDatafield.php | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/library/Director/Objects/DirectorDatafield.php b/library/Director/Objects/DirectorDatafield.php index ca6c2c8e..07627495 100644 --- a/library/Director/Objects/DirectorDatafield.php +++ b/library/Director/Objects/DirectorDatafield.php @@ -23,7 +23,6 @@ class DirectorDatafield extends DbObject protected $settings = array(); - public function set($key, $value) { if ($this->hasProperty($key)) { @@ -51,6 +50,20 @@ class DirectorDatafield extends DbObject return parent::get($key); } + public function __unset($key) + { + if ($this->hasProperty($key)) { + return parent::__set($key, $value); + } + + if (array_key_exists($key, $this->settings)) { + unset($this->settings[$key]); + $this->hasBeenModified = true; + } + + return $this; + } + public function getSettings() { return $this->settings; @@ -101,7 +114,7 @@ class DirectorDatafield extends DbObject } foreach ($del as $key) { - $db->update( + $db->delete( 'director_datafield_setting', $db->quoteInto($where, $key) );