From ce0a71aef73bb990e396ff5329aae31c3360f8ed Mon Sep 17 00:00:00 2001 From: AD7six Date: Thu, 23 Oct 2008 22:20:03 +0000 Subject: [PATCH] fixes #5603 Duplicate first parameter from the paginator with existing url args git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7777 3807eeeb-6ff5-0310-8944-8be069107fe0 --- cake/libs/controller/controller.php | 2 +- .../cases/libs/controller/controller.test.php | 33 +++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/cake/libs/controller/controller.php b/cake/libs/controller/controller.php index 7706a2105..ff2987725 100644 --- a/cake/libs/controller/controller.php +++ b/cake/libs/controller/controller.php @@ -956,7 +956,7 @@ class Controller extends Object { $count = count($keys); for ($i = 0; $i < $count; $i++) { - if (!in_array($keys[$i], $vars)) { + if (!in_array($keys[$i], $vars, true)) { unset($options[$keys[$i]]); } if (empty($whitelist) && ($keys[$i] === 'fields' || $keys[$i] === 'recursive')) { diff --git a/cake/tests/cases/libs/controller/controller.test.php b/cake/tests/cases/libs/controller/controller.test.php index 0488a8874..b7e08160b 100644 --- a/cake/tests/cases/libs/controller/controller.test.php +++ b/cake/tests/cases/libs/controller/controller.test.php @@ -565,6 +565,39 @@ class ControllerTest extends CakeTestCase { $this->assertEqual($Controller->ControllerPaginateModel->extra, $expected); $this->assertEqual($Controller->ControllerPaginateModel->extraCount, $expected); } +/** + * testPaginatePassedArgs method + * + * @return void + * @access public + */ + function testPaginatePassedArgs() { + $Controller =& new Controller(); + $Controller->uses = array('ControllerPost'); + $Controller->passedArgs[] = array('1', '2', '3'); + $Controller->params['url'] = array(); + $Controller->constructClasses(); + + $Controller->paginate = array( + 'fields' => array(), + 'order' => '', + 'limit' => 5, + 'page' => 1, + 'recursive' => -1 + ); + $conditions = array(); + $Controller->paginate('ControllerPost',$conditions); + + $expected = array( + 'fields' => array(), + 'order' => '', + 'limit' => 5, + 'page' => 1, + 'recursive' => -1, + 'conditions' => array() + ); + $this->assertEqual($Controller->params['paging']['ControllerPost']['options'],$expected); + } /** * testDefaultPaginateParams method *