From 81cbb52f74e9380f3b666c9bf609686b7ab23988 Mon Sep 17 00:00:00 2001 From: Mark Scherer Date: Tue, 22 Sep 2015 13:04:28 +0200 Subject: [PATCH] Only array-wrap 'order' if it's not already an array. --- lib/Cake/Model/Model.php | 2 +- .../Test/Case/Controller/Component/PaginatorComponentTest.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/Cake/Model/Model.php b/lib/Cake/Model/Model.php index 9ded1b59e..e0f64acab 100644 --- a/lib/Cake/Model/Model.php +++ b/lib/Cake/Model/Model.php @@ -3071,7 +3071,7 @@ class Model extends Object implements CakeEventListener { $query['order'] = $this->order; } - $query['order'] = array($query['order']); + $query['order'] = (array)$query['order']; if ($query['callbacks'] === true || $query['callbacks'] === 'before') { $event = new CakeEvent('Model.beforeFind', $this, array($query)); diff --git a/lib/Cake/Test/Case/Controller/Component/PaginatorComponentTest.php b/lib/Cake/Test/Case/Controller/Component/PaginatorComponentTest.php index 234d2dac3..a4113c102 100644 --- a/lib/Cake/Test/Case/Controller/Component/PaginatorComponentTest.php +++ b/lib/Cake/Test/Case/Controller/Component/PaginatorComponentTest.php @@ -361,13 +361,13 @@ class PaginatorComponentTest extends CakeTestCase { $Controller->request->params['named'] = array('sort' => 'NotExisting.field', 'direction' => 'desc', 'limit' => 2); $Controller->Paginator->paginate('PaginatorControllerPost'); $this->assertEquals(1, $Controller->params['paging']['PaginatorControllerPost']['page']); - $this->assertEquals(array(), $Controller->PaginatorControllerPost->lastQueries[1]['order'][0], 'no order should be set.'); + $this->assertEquals(array(), $Controller->PaginatorControllerPost->lastQueries[1]['order'], 'no order should be set.'); $Controller->request->params['named'] = array( 'sort' => 'PaginatorControllerPost.author_id', 'direction' => 'allYourBase' ); $results = Hash::extract($Controller->Paginator->paginate('PaginatorControllerPost'), '{n}.PaginatorControllerPost.id'); - $this->assertEquals(array('PaginatorControllerPost.author_id' => 'asc'), $Controller->PaginatorControllerPost->lastQueries[0]['order'][0]); + $this->assertEquals(array('PaginatorControllerPost.author_id' => 'asc'), $Controller->PaginatorControllerPost->lastQueries[0]['order']); $this->assertEquals(array(1, 3, 2), $results); $Controller->request->params['named'] = array();