diff --git a/placid/PlacidPlugin.php b/placid/PlacidPlugin.php index 08e4fb2..a792b63 100755 --- a/placid/PlacidPlugin.php +++ b/placid/PlacidPlugin.php @@ -10,7 +10,7 @@ function getName() } function getVersion() { - return '1.6.10'; + return '1.6.16'; } function getDeveloper() { diff --git a/placid/manifest.json b/placid/manifest.json index 461b23d..1412204 100644 --- a/placid/manifest.json +++ b/placid/manifest.json @@ -1,4 +1,13 @@ [ + { + "version": "1.6.16", + "downloadUrl": "https://github.com/alecritson/Placid/archive/master.zip", + "date": "2015-12-11T00:00:00+00:00", + "notes": [ + "# Bug Fixes", + "[Fixed] Fixed a bug where placid would return the wrong cached request for POST requests" + ] + }, { "version": "1.6.10", "downloadUrl": "https://github.com/alecritson/Placid/archive/master.zip", diff --git a/placid/services/Placid_RequestsService.php b/placid/services/Placid_RequestsService.php index 61f6dd4..281d704 100755 --- a/placid/services/Placid_RequestsService.php +++ b/placid/services/Placid_RequestsService.php @@ -32,6 +32,12 @@ class Placid_RequestsService extends PlacidService */ protected $config; + /** + * The cache id of the request + * @var String + */ + protected $cacheId; + public function __construct() { @@ -90,8 +96,7 @@ public function request($handle = null, array $config = array()) } // Get a cached request - $cachedRequest = craft()->placid_cache->get(base64_encode(urlencode($request->getUrl()))); - $caches = craft()->placid_cache->get(base64_encode(urlencode($request->getUrl()))); + $cachedRequest = craft()->placid_cache->get($this->_getCacheId()); // Import the onBeforeRequest event Craft::import('plugins.placid.events.PlacidBeforeRequestEvent'); @@ -318,6 +323,8 @@ private function _createRequest($client, $record = null) $this->config['url'] = $recordUrl; } + $this->cacheId = $this->config['url']; + $request = $client->createRequest($this->config['method'], $this->config['url']); if(array_key_exists('body', $this->config)) @@ -379,6 +386,11 @@ private function _createRequest($client, $record = null) } } + if($query) + { + $this->cacheId .= '?' . $query; + } + // Do we need to do some OAuth magic? if($provider = $record->getAttribute('oauth')) { @@ -453,7 +465,7 @@ private function _getResponse(Client $client, $request) if($this->config['cache']) { - craft()->placid_cache->set($request->getUrl(), $output, $this->config['duration']); + craft()->placid_cache->set($this->_getCacheId(), $output, $this->config['duration']); } return $output; @@ -523,4 +535,12 @@ private function _deleteWidgetsByRecord($id) return true; } + /** + * Returns the encoded cacheId for this request + * @return String The cache id + */ + private function _getCacheId() + { + return base64_encode(urlencode($this->cacheId)); + } }