Permalink
Browse files

array check to ensure getRemoteJoinField() gets an array from Config:…

…:inst()->get($remoteClass, 'has_one') (related issue: #2570)
  • Loading branch information...
1 parent 5c1a9d9 commit 8de1ce4a56b702845e12dd5aa0dd5b1bd0157079 @Zauberfisch Zauberfisch committed Oct 21, 2013
Showing with 6 additions and 2 deletions.
  1. +6 −2 model/DataObject.php
View
@@ -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) {

0 comments on commit 8de1ce4

Please sign in to comment.