diff --git a/cake/libs/model/model.php b/cake/libs/model/model.php index 69336b7d1..123bcd95f 100644 --- a/cake/libs/model/model.php +++ b/cake/libs/model/model.php @@ -1018,7 +1018,7 @@ class Model extends Overloadable { function hasField($name, $checkVirtual = false) { if (is_array($name)) { foreach ($name as $n) { - if ($this->hasField($n)) { + if ($this->hasField($n,$checkVirtual)) { return $n; } } diff --git a/cake/tests/cases/libs/controller/controller.test.php b/cake/tests/cases/libs/controller/controller.test.php index 5382e3d57..5fd099a5e 100644 --- a/cake/tests/cases/libs/controller/controller.test.php +++ b/cake/tests/cases/libs/controller/controller.test.php @@ -688,6 +688,24 @@ class ControllerTest extends CakeTestCase { $this->assertFalse(isset($Controller->params['paging']['ControllerPost']['options'][0])); } + function testPaginateOrderVirtualField() { + $Controller =& new Controller(); + $Controller->uses = array('ControllerPost', 'ControllerComment'); + $Controller->passedArgs[] = '1'; + $Controller->params['url'] = array(); + $Controller->constructClasses(); + $Controller->ControllerPost->virtualFields = array('offset_test' => 'ControllerPost.id + 1'); + + $Controller->paginate = array( + 'fields' => array('id', 'title'), + 'order' => 'offset_test', + 'limit' => 1 + ); + $result = $Controller->paginate('ControllerPost'); + + $this->assertEqual(Set::extract($result, '{n}.ControllerPost.offset_test'), array(2, 3)); + } + /** * testDefaultPaginateParams method *