diff --git a/code/dataobjects/DataChangeRecord.php b/code/dataobjects/DataChangeRecord.php index 8f28d53..cf8159b 100644 --- a/code/dataobjects/DataChangeRecord.php +++ b/code/dataobjects/DataChangeRecord.php @@ -87,12 +87,12 @@ public function getCMSFields($params = null) { ); if (strlen($this->Before)) { - $before = Object::create($this->ClassType, json_decode($this->Before, true), true); - $after = Object::create($this->ClassType, json_decode($this->After, true), true); + $before = Object::create($this->ClassType, $this->prepareForDataDifferencer($this->Before), true); + $after = Object::create($this->ClassType, $this->prepareForDataDifferencer($this->After), true); $diff = DataDifferencer::create($before, $after); - + // The solr search service injector dependency causes issues with comparison, since it has public variables that are stored in an array. - + $diff->ignoreFields(array('searchService')); $diffed = $diff->diffedData(); $diffText = ''; @@ -272,4 +272,21 @@ public function getMemberDetails(){ } } + /** + * @return array + */ + private function prepareForDataDifferencer($jsonData) + { + // NOTE(Jake): 2018-06-21 + // + // Data Differencer cannot handle arrays within an array, + // + // So JSON data that comes from MultiValueField / Text DB fields + // causes errors to be thrown. + // + // So solve this, we simply only decode to a depth of 1. (rather than the 512 default) + // + $jsonData = json_decode($jsonData, true, 1); + return $jsonData; + } }