From cb60fa5ddd4b3b76d4c55cb80a227f98bc983913 Mon Sep 17 00:00:00 2001 From: Qiang Xue Date: Thu, 29 Aug 2013 17:19:22 -0400 Subject: [PATCH] Make sure query cloning works as expected. --- framework/yii/data/ActiveDataProvider.php | 1 - framework/yii/db/ActiveRelation.php | 10 ++++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/framework/yii/data/ActiveDataProvider.php b/framework/yii/data/ActiveDataProvider.php index e36ef90..aaf71b2 100644 --- a/framework/yii/data/ActiveDataProvider.php +++ b/framework/yii/data/ActiveDataProvider.php @@ -9,7 +9,6 @@ namespace yii\data; use Yii; use yii\base\InvalidConfigException; -use yii\base\InvalidParamException; use yii\base\Model; use yii\db\Query; use yii\db\ActiveQuery; diff --git a/framework/yii/db/ActiveRelation.php b/framework/yii/db/ActiveRelation.php index 0eee25b..0be4feb 100644 --- a/framework/yii/db/ActiveRelation.php +++ b/framework/yii/db/ActiveRelation.php @@ -50,6 +50,16 @@ class ActiveRelation extends ActiveQuery */ public $via; + /** + * Clones internal objects. + */ + public function __clone() + { + if (is_object($this->via)) { + // make a clone of "via" object so that the same query object can be reused multiple times + $this->via = clone $this->via; + } + } /** * Specifies the relation associated with the pivot table.