mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
Allow empty has_one returns in DataDifferencer
Sometimes the has_one getter is incorrectly implemented, resulting in an empty return object. While that's technically a core API validation, there's no checks around it (i.e. no PHP class interface). DataDifferencer has the option to continue here, so we should program it defensively rather than resulting in a fatal error.
This commit is contained in:
parent
64f220617d
commit
8f5932acec
@ -116,7 +116,11 @@ class DataDifferencer extends ViewableData {
|
||||
$toTitle = '';
|
||||
if($this->toRecord->hasMethod($relName)) {
|
||||
$relObjTo = $this->toRecord->$relName();
|
||||
$toTitle = $relObjTo->hasMethod('Title') || $relObjTo->hasField('Title') ? $relObjTo->Title : '';
|
||||
if($relObjTo) {
|
||||
$toTitle = ($relObjTo->hasMethod('Title') || $relObjTo->hasField('Title')) ? $relObjTo->Title : '';
|
||||
} else {
|
||||
$toTitle = '';
|
||||
}
|
||||
}
|
||||
|
||||
if(!$this->fromRecord) {
|
||||
@ -134,7 +138,12 @@ class DataDifferencer extends ViewableData {
|
||||
$fromTitle = '';
|
||||
if($this->fromRecord->hasMethod($relName)) {
|
||||
$relObjFrom = $this->fromRecord->$relName();
|
||||
$fromTitle = $relObjFrom->hasMethod('Title') || $relObjFrom->hasField('Title') ? $relObjFrom->Title : '';
|
||||
if($relObjFrom) {
|
||||
$fromTitle = ($relObjFrom->hasMethod('Title') || $relObjFrom->hasField('Title')) ? $relObjFrom->Title : '';
|
||||
} else {
|
||||
$fromTitle = '';
|
||||
}
|
||||
|
||||
}
|
||||
if(isset($relObjFrom) && $relObjFrom instanceof Image) {
|
||||
// TODO Use CMSThumbnail (see above)
|
||||
|
Loading…
x
Reference in New Issue
Block a user