Skip to content

Commit

Permalink
fix(DependencyInject): Fix bug where 'WorkflowService'/'BlockManager'…
Browse files Browse the repository at this point in the history
… break the page due to not being able to render 'forTemplate'. This changes the fields value to say '[Missing BlockManager::forTemplate]' instead to avoid the page breaking entirely.
  • Loading branch information
Jake Bentvelzen authored and Nathan Glasl committed May 20, 2016
1 parent 2fcf619 commit ee4da88
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions code/dataobjects/DataChangeRecord.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit ee4da88

Please sign in to comment.