Merge pull request #15702 from developeruz/15696-magic-getter-for-AR

Fix magic getter for ActiveRecord (#15696)
This commit is contained in:
Dmitry Naumenko
2018-02-21 08:22:32 +02:00
committed by GitHub
4 changed files with 15 additions and 4 deletions

View File

@@ -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)

View File

@@ -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;
}

View File

@@ -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();
}
}

View File

@@ -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);
}
}