Commit 11baf619 by Qiang Xue

Fixed unsetting relation bug.

parent 4d538d6b
...@@ -251,7 +251,7 @@ class Component extends Object ...@@ -251,7 +251,7 @@ class Component extends Object
} }
} }
} }
throw new InvalidCallException('Unsetting an unknown or read-only property: ' . get_class($this) . '.' . $name); throw new InvalidCallException('Unsetting an unknown or read-only property: ' . get_class($this) . '::' . $name);
} }
/** /**
......
...@@ -303,14 +303,12 @@ abstract class BaseActiveRecord extends Model implements ActiveRecordInterface ...@@ -303,14 +303,12 @@ abstract class BaseActiveRecord extends Model implements ActiveRecordInterface
{ {
if ($this->hasAttribute($name)) { if ($this->hasAttribute($name)) {
unset($this->_attributes[$name]); unset($this->_attributes[$name]);
} else { } elseif (array_key_exists($name, $this->_related)) {
if (isset($this->_related[$name])) {
unset($this->_related[$name]); unset($this->_related[$name]);
} else { } else {
parent::__unset($name); parent::__unset($name);
} }
} }
}
/** /**
* Declares a `has-one` relation. * Declares a `has-one` relation.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment