Remove deprecated method className() for branch 2.2. (#19894)

This commit is contained in:
Wilmer Arambula
2023-07-16 09:45:39 -04:00
committed by GitHub
parent 9a5e2a5403
commit c9c100acd7
142 changed files with 518 additions and 526 deletions

View File

@ -189,7 +189,11 @@ class UniqueValidator extends Validator
/** @var ActiveRecordInterface|\yii\base\BaseObject $targetClass $query */
$query = $this->prepareQuery($targetClass, $conditions);
if (!$model instanceof ActiveRecordInterface || $model->getIsNewRecord() || $model::className() !== $targetClass::className()) {
if (
!$model instanceof ActiveRecordInterface ||
$model->getIsNewRecord() ||
!$model instanceof $targetClass
) {
// if current $model isn't in the database yet, then it's OK just to call exists()
// also there's no need to run check based on primary keys, when $targetClass is not the same as $model's class
$exists = $query->exists();