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:
Damian Mooyman 2018-02-05 14:18:44 +13:00 committed by GitHub
commit aca1e16b8e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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) {