diff --git a/framework/CHANGELOG.md b/framework/CHANGELOG.md index c1b1d2d7de..e199f2cb20 100644 --- a/framework/CHANGELOG.md +++ b/framework/CHANGELOG.md @@ -4,7 +4,7 @@ Yii Framework 2 Change Log 2.0.15 under development ------------------------ -- no changes in this release. +- Bug #15696: Fix magic getter for ActiveRecord (developeruz) 2.0.14 February 18, 2018 @@ -20,7 +20,7 @@ Yii Framework 2 Change Log - Bug #14296: Fixed log targets to throw exception in case log can not be properly exported (bizley) - Bug #14484: Fixed `yii\validators\UniqueValidator` for target classes with a default scope (laszlovl, developeruz) - Bug #14604: Fixed `yii\validators\CompareValidator` `compareAttribute` does not work if `compareAttribute` form ID has been changed (mikk150) -- Bug #14711 (CVE-2018-6010): Fixed `yii\web\ErrorHandler` displaying exception message in non-debug mode (samdark) +- Bug #14711: (CVE-2018-6010): Fixed `yii\web\ErrorHandler` displaying exception message in non-debug mode (samdark) - Bug #14811: Fixed `yii\filters\HttpCache` to work with PHP 7.2 (samdark) - Bug #14859: Fixed OCI DB `defaultSchema` failure when `masterConfig` is used (lovezhl456) - Bug #14903: Fixed route with extra dashes is executed controller while it should not (developeruz) @@ -122,7 +122,7 @@ Yii Framework 2 Change Log - Enh #15422: Added default roles dynamic definition support via closure for `yii\rbac\BaseManager` (deltacube) - Enh #15426: Added abilitiy to create and drop database views (igravity, vladis84) - Enh #15476: Added `\yii\widgets\ActiveForm::$validationStateOn` to be able to specify where to add class for invalid fields (samdark) -- Enh #15496 (CVE-2018-6009): CSRF token is now regenerated on changing identity (samdark, rhertogh) +- Enh #15496: (CVE-2018-6009): CSRF token is now regenerated on changing identity (samdark, rhertogh) - Enh #15595: `yii\data\DataFilter` can now handle `lt`,`gt`,`lte` and `gte` on `yii\validators\DateValidator` (mikk150) - Enh #15661: Added `yii\db\ExpressionInterface` support to `yii\db\Command::batchInsert()` (silverfire) - Enh: Added check to `yii\base\Model::formName()` to prevent source path disclosure when form is represented by an anonymous class (silverfire) diff --git a/framework/db/BaseActiveRecord.php b/framework/db/BaseActiveRecord.php index 81dfe90d17..3a5e9e6a05 100644 --- a/framework/db/BaseActiveRecord.php +++ b/framework/db/BaseActiveRecord.php @@ -1728,7 +1728,7 @@ abstract class BaseActiveRecord extends Model implements ActiveRecordInterface */ private function setRelationDependencies($name, $relation) { - if (empty($relation->via)) { + if (empty($relation->via) && $relation->link) { foreach ($relation->link as $attribute) { $this->_relationsDependencies[$attribute][$name] = $name; } diff --git a/tests/data/ar/OrderItem.php b/tests/data/ar/OrderItem.php index d0df2902e4..36fab6c369 100644 --- a/tests/data/ar/OrderItem.php +++ b/tests/data/ar/OrderItem.php @@ -44,4 +44,9 @@ class OrderItem extends ActiveRecord { return $this->hasOne(self::className(), ['item_id' => 'item_id', 'order_id' => 'order_id']); } + + public function getCustom() + { + return Order::find(); + } } diff --git a/tests/framework/db/ActiveRecordTest.php b/tests/framework/db/ActiveRecordTest.php index bb4b84700c..986332c0c5 100644 --- a/tests/framework/db/ActiveRecordTest.php +++ b/tests/framework/db/ActiveRecordTest.php @@ -1725,4 +1725,10 @@ abstract class ActiveRecordTest extends DatabaseTestCase ->all(); $this->assertCount(3, $orders); } + + public function testCustomARRelation() + { + $orderItem = OrderItem::findOne(1); + $this->assertInstanceOf(Order::class, $orderItem->custom); + } }