diff --git a/CHANGELONG.md b/CHANGELONG.md index 9353fb6..f851903 100755 --- a/CHANGELONG.md +++ b/CHANGELONG.md @@ -4,6 +4,16 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +## 1.0.4 - 2018-04-19 +### Updated +- `RestDispatch::preDispatch` should set the $request_uri from `CacheApiTrait::getRequestUri` and not use +`WP_REST_Request::get_route` to avoid query parameters getting stripped out of the cache request. +- `CacheApiTrait::getRequestUri` to sanitize the REQUEST_URI + +## 1.0.3 - 2018-04-18 +### Updated +- Bumped [thefrosty/wp-utilities](https://github.com/thefrosty/wp-utilities/) to version 1.1.3 + ## 1.0.2 - 2018-04-18 ### Updated - Bumped [thefrosty/wp-utilities](https://github.com/thefrosty/wp-utilities/) to version 1.1.2 diff --git a/composer.json b/composer.json index cebeb55..94fd82e 100755 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "dwnload/wp-rest-api-object-cache", "description": "Enable object caching for WordPress' REST API. Aids in increased response times of your applications endpoints.", "type": "wordpress-plugin", - "version": "1.0.3", + "version": "1.0.4", "license": "MIT", "authors": [ { diff --git a/src/RestApi/CacheApiTrait.php b/src/RestApi/CacheApiTrait.php index fd20676..a95d1ca 100644 --- a/src/RestApi/CacheApiTrait.php +++ b/src/RestApi/CacheApiTrait.php @@ -86,11 +86,10 @@ protected function wpCacheDeleteByKey(string $key) : bool * Return the current REQUEST_URI from the global server variable. * Don't use `FILTER_SANITIZE_URL` since it will return false when 'http' isn't present. * - * @param string|null $route The request route. * @return string */ - protected function getRequestUri(string $route = null) : string + protected function getRequestUri() : string { - return filter_var_string($route ?? $_SERVER['REQUEST_URI']); + return filter_var_string(wp_unslash($_SERVER['REQUEST_URI'])); } } diff --git a/src/RestApi/RestDispatch.php b/src/RestApi/RestDispatch.php index dbcfa9a..ca6d703 100644 --- a/src/RestApi/RestDispatch.php +++ b/src/RestApi/RestDispatch.php @@ -62,7 +62,7 @@ public function addHooks() */ public function preDispatch($result, WP_REST_Server $server, WP_REST_Request $request) { - $request_uri = $request->get_route() ?? $this->getRequestUri(); + $request_uri = $this->getRequestUri(); $group = $this->getCacheGroup(); $key = $this->getCacheKey($request_uri, $server, $request);