Fix Model::__clone() (#19291)

* Fix Model::__clone()

Reset validators and errors after cloning to prevent changing cloned model via inner objects of clone like as InlineValidator

* Update CHANGELOG.md

Co-authored-by: Bizley <pawel@positive.codes>
This commit is contained in:
Anton
2022-03-09 10:02:51 +03:00
committed by GitHub
parent b1e51dccd9
commit f3473aa4e8
2 changed files with 12 additions and 0 deletions

View File

@ -6,6 +6,7 @@ Yii Framework 2 Change Log
- Bug #19243: Handle `finfo_open` for tar.xz as `application/octet-stream` on PHP 8.1 (longthanhtran) - Bug #19243: Handle `finfo_open` for tar.xz as `application/octet-stream` on PHP 8.1 (longthanhtran)
- Bug #19235: Fix return type compatibility of `yii\web\SessionIterator` class methods for PHP 8.1 (virtual-designer) - Bug #19235: Fix return type compatibility of `yii\web\SessionIterator` class methods for PHP 8.1 (virtual-designer)
- Bug #19291: Reset errors and validators in `yii\base\Model::__clone()` (WinterSilence)
2.0.45 February 11, 2022 2.0.45 February 11, 2022

View File

@ -1052,4 +1052,15 @@ class Model extends Component implements StaticInstanceInterface, IteratorAggreg
{ {
$this->$offset = null; $this->$offset = null;
} }
/**
* {@inheritdoc}
*/
public function __clone()
{
parent::__clone();
$this->_errors = null;
$this->_validators = null;
}
} }