From adefb973aa28879dee9acb36f11a2af0d944be34 Mon Sep 17 00:00:00 2001 From: Trent Renshaw Date: Thu, 31 May 2018 15:42:48 +1000 Subject: [PATCH] Replaced is_array() check and set of $keys in array with cast to array of $keys in array_filter() Replaced assignment of $key and $dir through list() with each() with simply key() and current() per tenkoma's suggestion. Resolves # 11827 each() advances the pointer similar to next() but is being negated this particular case by array_shift() which resets the pointer --- lib/Cake/Model/Datasource/DboSource.php | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/lib/Cake/Model/Datasource/DboSource.php b/lib/Cake/Model/Datasource/DboSource.php index a8481a38a..40b794dde 100644 --- a/lib/Cake/Model/Datasource/DboSource.php +++ b/lib/Cake/Model/Datasource/DboSource.php @@ -3043,15 +3043,12 @@ class DboSource extends DataSource { * @return string ORDER BY clause */ public function order($keys, $direction = 'ASC', Model $Model = null) { - if (!is_array($keys)) { - $keys = array($keys); - } - - $keys = array_filter($keys); - + $keys = array_filter((array) $keys); + $result = array(); while (!empty($keys)) { - list($key, $dir) = each($keys); + $key = key($keys); + $dir = current($keys); array_shift($keys); if (is_numeric($key)) {