From 055cddb21f4436b074c1895839097c106b827be9 Mon Sep 17 00:00:00 2001 From: Jose Lorenzo Rodriguez Date: Mon, 22 Feb 2016 13:37:41 +0100 Subject: [PATCH] Filtering empty params out of the query string. This fixes errors caused by cahnges in cake 3.2.3 --- src/Controller/Component/PrgComponent.php | 10 +++++++++- src/Model/Behavior/SearchBehavior.php | 5 +++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/Controller/Component/PrgComponent.php b/src/Controller/Component/PrgComponent.php index afcab229..ba0dc32f 100644 --- a/src/Controller/Component/PrgComponent.php +++ b/src/Controller/Component/PrgComponent.php @@ -46,8 +46,16 @@ public function conversion($redirect = true) return null; } if ($redirect) { + $params = $this->request->data; + + foreach ($params as $k => $param) { + if (is_string($param) && strlen($param) === 0) { + unset($params[$k]); + } + } + return $this->_registry->getController()->redirect( - $this->request->params['pass'] + ['?' => $this->request->data] + $this->request->params['pass'] + ['?' => $params] ); } return null; diff --git a/src/Model/Behavior/SearchBehavior.php b/src/Model/Behavior/SearchBehavior.php index 494379b5..d8603962 100644 --- a/src/Model/Behavior/SearchBehavior.php +++ b/src/Model/Behavior/SearchBehavior.php @@ -68,6 +68,11 @@ public function findSearch(Query $query, array $options) */ public function filterParams($params) { + foreach ($params as $k => $param) { + if (is_string($param) && strlen($param) === 0) { + unset($params[$k]); + } + } return ['search' => array_intersect_key($params, $this->_getAllFilters())]; }