Browse Source

Fixing some issues from previous commits

Jose Lorenzo Rodriguez 10 years ago
parent
commit
d40f81f957

+ 2 - 2
src/Routing/Route/Route.php

@@ -442,7 +442,7 @@ class Route
             $hostOptions['_base'] = $context['_base'];
         }
 
-        $query = !empty($url['?']) ? array_filter((array)$url['?'], 'strlen') : [];
+        $query = !empty($url['?']) ? (array)$url['?'] : [];
         unset($url['_host'], $url['_scheme'], $url['_port'], $url['_base'], $url['?']);
 
         // Move extension into the hostOptions so its not part of
@@ -616,7 +616,7 @@ class Route
             $out .= '.' . $params['_ext'];
         }
         if (!empty($query)) {
-            $out .= '?' . http_build_query($query);
+            $out .= rtrim('?' . http_build_query($query), '?');
         }
         return $out;
     }

+ 1 - 3
src/View/Helper/PaginatorHelper.php

@@ -99,9 +99,7 @@ class PaginatorHelper extends Helper
         parent::__construct($View, $config);
 
         $query = $this->request->query;
-        if (isset($query['page']) && $query['page'] == 1) {
-            unset($query['page']);
-        }
+        unset($query['page'], $query['limit'], $query['sort'], $query['direction']);
         $this->config(
             'options.url',
             array_merge($this->request->params['pass'], ['?' => $query])

+ 1 - 1
tests/TestCase/View/Helper/PaginatorHelperTest.php

@@ -799,7 +799,7 @@ class PaginatorHelperTest extends TestCase
         ];
 
         $this->Paginator->request->params['pass'] = [2];
-        $this->Paginator->request->query = ['page' => 1, 'foo' => 'bar', 'x' => 'y', 'num' => 0, 'empty' => ''];
+        $this->Paginator->request->query = ['page' => 1, 'foo' => 'bar', 'x' => 'y', 'num' => 0];
         $this->View->request = $this->Paginator->request;
         $this->Paginator = new PaginatorHelper($this->View);