Skip to content

Commit fd56a39

Browse files
committed
1.5.1 Release
Fix caching behaviour
1 parent e549b41 commit fd56a39

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/Model/Api/ApiAbstract.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
use Skywire\WordpressApi\Model\Data\Collection;
2828
use Skywire\WordpressApi\Model\Data\CollectionFactory;
2929
use Skywire\WordpressApi\Model\RestClientFactory;
30+
use function GuzzleHttp\Psr7\str;
31+
use function GuzzleHttp\Psr7\parse_response;
3032

3133
/**
3234
* Description of class
@@ -175,14 +177,14 @@ protected function _parseRoute($id = '')
175177
* @param string $route
176178
* @param array $params
177179
*
178-
* @return \Zend_Http_Response
180+
* @return \GuzzleHttp\Psr7\Response
179181
*/
180182
protected function _request($route, $params = [])
181183
{
182184
$cacheKey = $this->_getCacheKey($route, $params);
183185
$cached = $this->cache->load($cacheKey);
184186
if ($cached) {
185-
return unserialize($cached);
187+
return parse_response($cached);
186188
}
187189

188190
$client = $this->getRestClient();
@@ -194,7 +196,7 @@ protected function _request($route, $params = [])
194196
throw new ApiException($responseBody, $response->getStatusCode());
195197
}
196198

197-
$this->cache->save(serialize($response), $cacheKey, [], 3600 * 24);
199+
$this->cache->save(str($response), $cacheKey, [], 3600 * 24);
198200

199201
return $response;
200202
}

src/etc/module.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0"?>
22
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
3-
<module name="Skywire_WordpressApi" setup_version="1.5.0">
3+
<module name="Skywire_WordpressApi" setup_version="1.5.1">
44
</module>
55
</config>

0 commit comments

Comments
 (0)