Commit cb60fa5d by Qiang Xue

Make sure query cloning works as expected.

parent 30d62299
...@@ -9,7 +9,6 @@ namespace yii\data; ...@@ -9,7 +9,6 @@ namespace yii\data;
use Yii; use Yii;
use yii\base\InvalidConfigException; use yii\base\InvalidConfigException;
use yii\base\InvalidParamException;
use yii\base\Model; use yii\base\Model;
use yii\db\Query; use yii\db\Query;
use yii\db\ActiveQuery; use yii\db\ActiveQuery;
......
...@@ -50,6 +50,16 @@ class ActiveRelation extends ActiveQuery ...@@ -50,6 +50,16 @@ class ActiveRelation extends ActiveQuery
*/ */
public $via; 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. * Specifies the relation associated with the pivot table.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment