diff --git a/cake/libs/controller/controller.php b/cake/libs/controller/controller.php index 2b730e06f..06b6a1077 100644 --- a/cake/libs/controller/controller.php +++ b/cake/libs/controller/controller.php @@ -985,9 +985,12 @@ class Controller extends Object { if (isset($defaults[0])) { $type = array_shift($defaults); } - $extra = array_diff_key($defaults, compact( + $extra = array_diff_assoc($defaults, compact( 'conditions', 'fields', 'order', 'limit', 'page', 'recursive' )); + if ($type !== 'all') { + $extra['type'] = $type; + } if (method_exists($object, 'paginateCount')) { $count = $object->paginateCount($conditions, $recursive, $extra); diff --git a/cake/tests/cases/libs/controller/controller.test.php b/cake/tests/cases/libs/controller/controller.test.php index 3d20e68b9..11daeddd3 100644 --- a/cake/tests/cases/libs/controller/controller.test.php +++ b/cake/tests/cases/libs/controller/controller.test.php @@ -493,11 +493,20 @@ class ControllerTest extends CakeTestCase { $Controller->params['url'] = array(); $Controller->constructClasses(); $Controller->paginate = array( - 'ControllerPaginateModel' => array('contain' => array('ControllerPaginateModel'), 'group' => 'Comment.author_id')); + 'ControllerPaginateModel' => array('contain' => array('ControllerPaginateModel'), 'group' => 'Comment.author_id') + ); $result = $Controller->paginate('ControllerPaginateModel'); $expected = array('contain' => array('ControllerPaginateModel'), 'group' => 'Comment.author_id'); $this->assertEqual($Controller->ControllerPaginateModel->extra, $expected); $this->assertEqual($Controller->ControllerPaginateModel->extraCount, $expected); + + $Controller->paginate = array( + 'ControllerPaginateModel' => array('foo', 'contain' => array('ControllerPaginateModel'), 'group' => 'Comment.author_id') + ); + $Controller->paginate('ControllerPaginateModel'); + $expected = array('contain' => array('ControllerPaginateModel'), 'group' => 'Comment.author_id', 'type' => 'foo'); + $this->assertEqual($Controller->ControllerPaginateModel->extra, $expected); + $this->assertEqual($Controller->ControllerPaginateModel->extraCount, $expected); } /** * testDefaultPaginateParams method