Skip to content

Commit

Permalink
Replaced is_array() check and set of $keys in array with cast to arra…
Browse files Browse the repository at this point in the history
…y 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
  • Loading branch information
Trent Renshaw committed May 31, 2018
1 parent fc061a5 commit adefb97
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions lib/Cake/Model/Datasource/DboSource.php
Expand Up @@ -3043,15 +3043,12 @@ public function limit($limit, $offset = null) {
* @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)) {
Expand Down

0 comments on commit adefb97

Please sign in to comment.