mirror of
https://github.com/yiisoft/yii2.git
synced 2025-08-26 14:26:54 +08:00
Fixes #16558: Added cloning yii\data\ActiveDataProvider::query
property when ActiveDataProvider object is cloned
This commit is contained in:

committed by
Alexander Makarov

parent
0ddc3bf58c
commit
e53fc0ded1
@ -3,6 +3,8 @@ Yii Framework 2 Change Log
|
||||
|
||||
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 #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)
|
||||
|
@ -196,4 +196,13 @@ class ActiveDataProvider extends BaseDataProvider
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function __clone()
|
||||
{
|
||||
if (is_object($this->query)) {
|
||||
$this->query = clone $this->query;
|
||||
}
|
||||
|
||||
parent::__clone();
|
||||
}
|
||||
}
|
||||
|
34
tests/framework/data/ActiveDataProviderCloningTest.php
Normal file
34
tests/framework/data/ActiveDataProviderCloningTest.php
Normal 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);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user