mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge pull request #6211 from jason-zz/patch-3
BUG Fix : relObject() should return null if one of the node is null
This commit is contained in:
commit
aca1e16b8e
@ -3071,8 +3071,11 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
|||||||
$relations = explode('.', $fieldName);
|
$relations = explode('.', $fieldName);
|
||||||
$fieldName = array_pop($relations);
|
$fieldName = array_pop($relations);
|
||||||
foreach($relations as $relation) {
|
foreach($relations as $relation) {
|
||||||
|
// Bail if the component is null
|
||||||
|
if(!$component) {
|
||||||
|
return null;
|
||||||
// Inspect $component for element $relation
|
// Inspect $component for element $relation
|
||||||
if($component->hasMethod($relation)) {
|
} elseif($component->hasMethod($relation)) {
|
||||||
// Check nested method
|
// Check nested method
|
||||||
$component = $component->$relation();
|
$component = $component->$relation();
|
||||||
} elseif($component instanceof SS_List) {
|
} elseif($component instanceof SS_List) {
|
||||||
|
Loading…
Reference in New Issue
Block a user