Skip to content
This repository
Browse code

BUGFIX: Tidied up relObject() behaviour on DataLists to restore broke…

…n SearchContext functionality.
  • Loading branch information...
commit 58433d38ced3d255d2704271cc80a7f163cad910 1 parent c56176c
Sam Minnée authored March 30, 2012
4  model/DataList.php
@@ -668,6 +668,10 @@ public function relation($relationName) {
668 668
 		return singleton($this->dataClass)->$relationName()->forForeignID($ids);
669 669
 	}
670 670
 
  671
+	function dbObject($fieldName) {
  672
+		return singleton($this->dataClass)->dbObject($fieldName);
  673
+	}
  674
+
671 675
 	/**
672 676
 	 * Add a number of items to the component set.
673 677
 	 * 
14  model/DataObject.php
@@ -2404,7 +2404,12 @@ public function relObject($fieldPath) {
2404 2404
 			// Traverse dot syntax
2405 2405
 			$component = $this;
2406 2406
 			foreach($parts as $relation) {
2407  
-				$component = $component->$relation();
  2407
+				if($component instanceof SS_List) {
  2408
+					if(method_exists($component,$relation)) $component = $component->$relation();
  2409
+					else $component = $component->relation($relation);
  2410
+				} else {
  2411
+					$component = $component->$relation();
  2412
+				}
2408 2413
 			}
2409 2414
 
2410 2415
 			$object = $component->dbObject($fieldName);
@@ -2436,7 +2441,12 @@ public function relField($fieldPath) {
2436 2441
 			// Traverse dot syntax
2437 2442
 			$component = $this;
2438 2443
 			foreach($parts as $relation) {
2439  
-				$component = $component->$relation();
  2444
+				if($component instanceof SS_List) {
  2445
+					if(method_exists($component,$relation)) $component = $component->$relation();
  2446
+					else $component = $component->relation($relation);
  2447
+				} else {
  2448
+					$component = $component->$relation();
  2449
+				}
2440 2450
 			}
2441 2451
 
2442 2452
 			return $component->$fieldName;

0 notes on commit 58433d3

Please sign in to comment.
Something went wrong with that request. Please try again.