Skip to content

Commit

Permalink
array check to ensure getRemoteJoinField() gets an array from Config:…
Browse files Browse the repository at this point in the history
…:inst()->get($remoteClass, 'has_one') (related issue: #2570)
  • Loading branch information
Zauberfisch committed Oct 21, 2013
1 parent 5c1a9d9 commit 8de1ce4
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions model/DataObject.php
Expand Up @@ -1532,8 +1532,12 @@ public function getRemoteJoinField($component, $type = 'has_many') {
if($fieldPos = strpos($remoteClass, '.')) {
return substr($remoteClass, $fieldPos + 1) . 'ID';
}

$remoteRelations = array_flip(Config::inst()->get($remoteClass, 'has_one'));

$remoteRelations = Config::inst()->get($remoteClass, 'has_one');
if(!is_array($remoteRelations)) {
$remoteRelations = array();
}
$remoteRelations = array_flip($remoteRelations);

// look for remote has_one joins on this class or any parent classes
foreach(array_reverse(ClassInfo::ancestry($this)) as $class) {
Expand Down

0 comments on commit 8de1ce4

Please sign in to comment.