From 6676ef0ee93177251d128c7bd39e51447cafebae Mon Sep 17 00:00:00 2001 From: Austin Passy Date: Thu, 19 Apr 2018 10:03:40 -0700 Subject: [PATCH 1/3] Remove the route parameter and stripslashes deep on the REQUEST URI. --- src/RestApi/CacheApiTrait.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) 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'])); } } From a78f519b98b498716f41e1fe6daed34e49f0f250 Mon Sep 17 00:00:00 2001 From: Austin Passy Date: Thu, 19 Apr 2018 10:05:24 -0700 Subject: [PATCH 2/3] Remove the WP_REST_Request route from the $request_uri and the the $_SERVER request so query params don't get lost. --- src/RestApi/RestDispatch.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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); From b5874b1453339afb12e2f25ca4a4b750093703a6 Mon Sep 17 00:00:00 2001 From: Austin Passy Date: Thu, 19 Apr 2018 10:05:36 -0700 Subject: [PATCH 3/3] Version bump to 1.0.4. --- CHANGELONG.md | 10 ++++++++++ composer.json | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) 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": [ {