소스 검색

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)

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@3964 a333f486-631f-4898-b8df-5754b55c2be0
romainq 9 년 전
부모
커밋
6c3e4f17ae
2개의 변경된 파일10개의 추가작업 그리고 1개의 파일을 삭제
  1. 7 0
      core/customfieldshandler.class.inc.php
  2. 3 1
      core/ormcustomfieldsvalue.class.inc.php

+ 7 - 0
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);
 }

+ 3 - 1
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);
 	}
 }