Only array-wrap 'order' if it's not already an array.

This commit is contained in:
Mark Scherer 2015-09-22 13:04:28 +02:00
parent 851ff44b4c
commit 81cbb52f74
2 changed files with 3 additions and 3 deletions

View file

@ -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));

View file

@ -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();