diff --git a/app/code/community/Lesti/Fpc/Helper/Data.php b/app/code/community/Lesti/Fpc/Helper/Data.php index 6fabdc6..1c6ae24 100644 --- a/app/code/community/Lesti/Fpc/Helper/Data.php +++ b/app/code/community/Lesti/Fpc/Helper/Data.php @@ -216,7 +216,8 @@ public function canCacheRequest() foreach ($missParams as $missParam) { $pair = array_map('trim', explode('=', $missParam)); $key = $pair[0]; - $param = $request->getParam($key); + $param = $this->_paramToString($request->getParam($key)); + if ($param && isset($pair[1]) && preg_match($pair[1], $param)) { return false; } @@ -258,4 +259,30 @@ public function getContentType(\Mage_Core_Controller_Response_Http $response) return 'text/html; charset=UTF-8'; } + + /** + * Transform array parameter to string to avoid error and make correct validation in regexp pattern + * + * @param mixed $param Input parameter + * + * @return mixed + */ + protected function _paramToString($param) + { + if (is_array($param)) { + $param = array_reduce( + $param, + function ($carry, $item) { + if (!is_array($item)) { + return $carry . $item; + } + + return ''; + }, + '' + ); + } + + return $param; + } }