mirror of
https://github.com/yiisoft/yii2.git
synced 2025-12-19 07:07:58 +08:00
Fix magic getter for ActiveRecord (#15696)
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user