Fixes #16558: Added cloning yii\data\ActiveDataProvider::query property when ActiveDataProvider object is cloned

This commit is contained in:
Mikhail
2018-08-05 15:18:24 +03:00
committed by Alexander Makarov
parent 0ddc3bf58c
commit e53fc0ded1
3 changed files with 45 additions and 0 deletions

View File

@ -3,6 +3,8 @@ Yii Framework 2 Change Log
2.0.16 under development 2.0.16 under development
------------------------ ------------------------
- Bug #16558: Added cloning `yii\data\ActiveDataProvider::query` property when ActiveDataProvider object is cloned (mgrechanik)
- Bug #14901: Fixed trim validation for radio/checkbox button (s1lver) - Bug #14901: Fixed trim validation for radio/checkbox button (s1lver)
- Bug #16527: Fixed return content for `\yii\widgets\ActiveForm::run()` (carono) - Bug #16527: Fixed return content for `\yii\widgets\ActiveForm::run()` (carono)
- Bug #15826: Fixed JavaScript compareValidator in `yii.validation.js` for attributes not in rules (mgrechanik) - Bug #15826: Fixed JavaScript compareValidator in `yii.validation.js` for attributes not in rules (mgrechanik)

View File

@ -196,4 +196,13 @@ class ActiveDataProvider extends BaseDataProvider
} }
} }
} }
public function __clone()
{
if (is_object($this->query)) {
$this->query = clone $this->query;
}
parent::__clone();
}
} }

View File

@ -0,0 +1,34 @@
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace yiiunit\framework\data;
use yii\data\ActiveDataProvider;
use yii\db\Query;
use yiiunit\TestCase;
class ActiveDataProviderCloningTest extends TestCase
{
// Tests :
public function testClone()
{
$queryFirst = new Query();
$dataProviderFirst = new ActiveDataProvider([
'query' => $queryFirst
]);
$dataProviderSecond = clone $dataProviderFirst;
$querySecond = $dataProviderSecond->query;
$this->assertNotSame($querySecond, $queryFirst);
}
}