From 462af2715787bc0ec3a6adf22290a86be2927a13 Mon Sep 17 00:00:00 2001 From: Romain Quetiez Date: Tue, 22 Mar 2016 16:55:51 +0000 Subject: [PATCH] Custom fields: comparing two sets of values is delegated to the custom fields handler because the values must be interpreted before concluding (blind comparison resulted in objects being written though the values were equivalent) SVN:trunk[3964] --- core/customfieldshandler.class.inc.php | 7 +++++++ core/ormcustomfieldsvalue.class.inc.php | 4 +++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/core/customfieldshandler.class.inc.php b/core/customfieldshandler.class.inc.php index 19d21f1fe..2a4110bda 100644 --- a/core/customfieldshandler.class.inc.php +++ b/core/customfieldshandler.class.inc.php @@ -124,4 +124,11 @@ abstract class CustomFieldsHandler * Cleanup data upon object deletion (object id still available here) */ abstract public function DeleteValues(); + + /** + * @param $aValuesA + * @param $aValuesB + * @return bool + */ + abstract public function CompareValues($aValuesA, $aValuesB); } diff --git a/core/ormcustomfieldsvalue.class.inc.php b/core/ormcustomfieldsvalue.class.inc.php index b5d108a6c..42a1d686f 100644 --- a/core/ormcustomfieldsvalue.class.inc.php +++ b/core/ormcustomfieldsvalue.class.inc.php @@ -96,6 +96,8 @@ class ormCustomFieldsValue */ public function Equals(ormCustomFieldsValue $oReference) { - return (json_encode($this->aCurrentValues) === json_encode($oReference->aCurrentValues)); + $oAttDef = MetaModel::GetAttributeDef(get_class($this->oHostObject), $this->sAttCode); + $oHandler = $oAttDef->GetHandler($this->oHostObject, $this->GetValues()); + return $oHandler->CompareValues($this->aCurrentValues, $oReference->aCurrentValues); } }