From 67bd4972ba6b5bff2f84960698b7bf02887996e0 Mon Sep 17 00:00:00 2001 From: miramir Date: Mon, 7 Jul 2014 13:38:02 +0600 Subject: [PATCH] Check availabilty field in BaseActiveRecord::populateRecord check with Object::canSetProperty() fixes #4305, close #4211 --- framework/CHANGELOG.md | 3 ++- framework/db/BaseActiveRecord.php | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/framework/CHANGELOG.md b/framework/CHANGELOG.md index ad0fdd7..f597d89 100644 --- a/framework/CHANGELOG.md +++ b/framework/CHANGELOG.md @@ -186,8 +186,9 @@ Yii Framework 2 Change Log - Chg #4071: `mail` component renamed to `mailer`, `yii\log\EmailTarget::$mail` renamed to `yii\log\EmailTarget::$mailer` (samdark) - Chg #4147: `BaseMailer::compose()` will not overwrite the `message` parameter if it is explicitly provided (qiangxue) - Chg #4201: change default value of `SyslogTarget::facility` from LOG_SYSLOG to LOG_USER (dizews) +- Chg #4211: BaseActiveRecord::populateRecord now silently hide selected columns that are not defined in AR instead of failing with an error (miramir) - Chg #4227: `\yii\widgets\LinkPager::$hideOnSinglePage` is now `true` by default (samdark) -- Chg #4310: Removed `$data` from signature of `yii\rbac\ManagerInterface` (samdark) +- Chg #4310: Removed `$data` from signature of `yii\rbac\ManagerInterface` (samdark) - Chg #4318: `yii\helpers\Html::ul()` and `ol()` will return an empty list tag if an empty item array is given (qiangxue) - Chg #4331: `yii\helpers\Url` now uses `UrlManager` to determine base URL when generating URLs (qiangxue) - Chg: Replaced `clearAll()` and `clearAllAssignments()` in `yii\rbac\ManagerInterface` with `removeAll()`, `removeAllRoles()`, `removeAllPermissions()`, `removeAllRules()` and `removeAllAssignments()` (qiangxue) diff --git a/framework/db/BaseActiveRecord.php b/framework/db/BaseActiveRecord.php index 619a148..03b3144 100644 --- a/framework/db/BaseActiveRecord.php +++ b/framework/db/BaseActiveRecord.php @@ -1042,7 +1042,7 @@ abstract class BaseActiveRecord extends Model implements ActiveRecordInterface foreach ($row as $name => $value) { if (isset($columns[$name])) { $record->_attributes[$name] = $value; - } else { + } elseif ($record->canSetProperty($name)) { $record->$name = $value; } }