mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Only array-wrap 'order' if it's not already an array.
This commit is contained in:
parent
851ff44b4c
commit
81cbb52f74
2 changed files with 3 additions and 3 deletions
|
@ -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));
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in a new issue