Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #782 from jails/bug/entity-magic-call

Fix infinite loop that occurs when an `data\Entity` class is used as `data\Entity::_model`.
  • Loading branch information...
commit 56074bb9790afa0909e581e7217c42a23078a3a4 2 parents 0c9e1bd + 5f2fe23
@nateabele nateabele authored
Showing with 9 additions and 1 deletion.
  1. +1 −1  data/Entity.php
  2. +8 −0 tests/cases/data/EntityTest.php
View
2  data/Entity.php
@@ -187,7 +187,7 @@ public function __isset($name) {
* @return mixed
*/
public function __call($method, $params) {
- if ($model = $this->_model) {
+ if (($model = $this->_model) && method_exists($model, '_object')) {
array_unshift($params, $this);
$class = $model::invokeMethod('_object');
return call_user_func_array(array(&$class, $method), $params);
View
8 tests/cases/data/EntityTest.php
@@ -102,6 +102,14 @@ public function testMethodDispatchWithNoModel() {
$entity->foo();
}
+ public function testMethodDispatchWithEntityAsModel() {
+ $data = array('foo' => true);
+ $model = 'lithium\data\Entity';
+ $entity = new Entity(compact('model', 'data'));
+ $this->expectException("/^No model bound to call `foo`.$/");
+ $entity->foo();
+ }
+
public function testErrors() {
$entity = new Entity();
$errors = array('foo' => 'Something bad happened.');
Please sign in to comment.
Something went wrong with that request. Please try again.