From 8d591c95d188b29afede0fb21e71a2aec38aff0c Mon Sep 17 00:00:00 2001 From: James Moey Date: Wed, 23 May 2012 12:59:20 +1000 Subject: [PATCH] Fix for issue #591 CActiveRecord::getRelated doesn't call afterFind() with `through` relation It was only expecting joinTree only contain 1 child, if you use through relation, that might not be true. Therefore, use a loop to go though the children and call afterFind on them. --- framework/db/ar/CActiveFinder.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/framework/db/ar/CActiveFinder.php b/framework/db/ar/CActiveFinder.php index 6d38ccc10..b72e04815 100644 --- a/framework/db/ar/CActiveFinder.php +++ b/framework/db/ar/CActiveFinder.php @@ -167,8 +167,9 @@ class CActiveFinder extends CComponent $this->_joinTree->lazyFind($baseRecord); if(!empty($this->_joinTree->children)) { - $child=reset($this->_joinTree->children); - $child->afterFind(); + foreach($this->_joinTree->children as $child) { + $child->afterFind(); + } } $this->destroyJoinTree(); }