Permalink
Browse files

Test if keys are empty before sorting

  • Loading branch information...
1 parent 9be789d commit d40452b43d50f11c078c432583c4d67be8bbb9f7 Mike Gibson committed Mar 10, 2014
Showing with 8 additions and 4 deletions.
  1. +8 −4 lib/Cake/Routing/Route/CakeRoute.php
View
12 lib/Cake/Routing/Route/CakeRoute.php
@@ -519,10 +519,14 @@ protected function _writeUrl($params) {
$search = $replace = array();
- $lengths = array_map('strlen', $this->keys);
- $flipped = array_combine($this->keys, $lengths);
- arsort($flipped);
- $keys = array_keys($flipped);
+ if(empty($this->keys)) {
+ $keys = array();
+ } else {
+ $lengths = array_map('strlen', $this->keys);
+ $flipped = array_combine($this->keys, $lengths);
+ arsort($flipped);
+ $keys = array_keys($flipped);
+ }
foreach ($keys as $key) {
$string = null;

0 comments on commit d40452b

Please sign in to comment.