Fix PHP 8.1 Empty header DataColumn (#19350)

* Fix PHP 8.1 Empty header DataColumn

#19349

* Update CHANGELOG.md

* Update CHANGELOG.md

Co-authored-by: Bizley <pawel@positive.codes>
This commit is contained in:
Evgeniy Tkachenko
2022-04-13 18:58:28 +03:00
committed by GitHub
parent 0741c4cab0
commit ad1fd84f39
2 changed files with 4 additions and 1 deletions

View File

@ -4,6 +4,7 @@ Yii Framework 2 Change Log
2.0.46 under development
------------------------
- Bug #19349: Fix PHP 8.1 error when attribute and label of `yii\grid\DataColumn` are empty (githubjeka)
- 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 #19256: Pass missed `$view` to user's callback in `yii\validators\InlineValidator::clientValidateAttribute()` (WinterSilence)

View File

@ -167,7 +167,9 @@ class DataColumn extends Column
$provider = $this->grid->dataProvider;
if ($this->label === null) {
if ($provider instanceof ActiveDataProvider && $provider->query instanceof ActiveQueryInterface) {
if ($this->attribute === null) {
$label = '';
} elseif ($provider instanceof ActiveDataProvider && $provider->query instanceof ActiveQueryInterface) {
/* @var $modelClass Model */
$modelClass = $provider->query->modelClass;
$model = $modelClass::instance();