Browse files

MINOR Checking for valid field type in DataDifferencer (built-in fiel…

…ds like 'RecordClassName' can't be casted to a field object)
  • Loading branch information...
1 parent f37640b commit 67568b08a37533ba8a061491c32301854d9f1b1b @chillu chillu committed Sep 15, 2011
Showing with 16 additions and 1 deletion.
  1. +16 −1 model/DataDifferencer.php
View
17 model/DataDifferencer.php
@@ -153,7 +153,22 @@ function ChangedFields() {
foreach($fields as $field) {
if(in_array($field, $this->ignoredFields)) continue;
- if(!$this->fromRecord || $this->fromRecord->$field != $this->toRecord->$field) {
+ if(!$this->fromRecord || $this->fromRecord->$field != $this->toRecord->$field) {
+ // Only show HTML diffs for fields which allow HTML values in the first place
+ $fieldObj = $this->toRecord->dbObject($field);
+ if($this->fromRecord) {
+ $fieldDiff = Diff::compareHTML(
+ $this->fromRecord->$field,
+ $this->toRecord->$field,
+ (!$fieldObj || $fieldObj->stat('escape_type') != 'xml')
+ );
+ } else {
+ if($fieldObj && $fieldObj->stat('escape_type') == 'xml') {
+ $fieldDiff = "<ins>" . $this->toRecord->$field . "</ins>";
+ } else {
+ $fieldDiff = "<ins>" . Convert::raw2xml($this->toRecord->$field) . "</ins>";
+ }
+ }
$changedFields->push(new ArrayData(array(
'Name' => $field,
'Title' => $base->fieldLabel($field),

0 comments on commit 67568b0

Please sign in to comment.