diff --git a/code/dataobjects/DataChangeRecord.php b/code/dataobjects/DataChangeRecord.php index 3d36ada..f91d087 100644 --- a/code/dataobjects/DataChangeRecord.php +++ b/code/dataobjects/DataChangeRecord.php @@ -108,6 +108,21 @@ public function getCMSFields($params = null) { ); } + // Flags fields that cannot be rendered with 'forTemplate'. This prevents bugs where + // WorkflowService (of AdvancedWorkflow Module) and BlockManager (of Sheadawson/blocks module) get put + // into a field and break the page. + $fieldsToRemove = array(); + foreach ($fields->dataFields() as $field) + { + $value = $field->Value(); + if ($value && is_object($value)) + { + if (($value instanceof Object && !$value->hasMethod('forTemplate')) || !method_exists($value, 'forTemplate')) { + $field->setValue('[Missing '.get_class($value).'::forTemplate]'); + } + } + } + $fields = $fields->makeReadonly(); return $fields;