mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
BUG Fix : relObject() should return null if one of the node is null
This commit is contained in:
parent
0f8f9f2732
commit
8e5bb6fbdc
@ -3069,8 +3069,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