Skip to content

Commit

Permalink
Bugfix: Responses were not cached properly
Browse files Browse the repository at this point in the history
  • Loading branch information
demianh committed Aug 27, 2024
1 parent 4ff3b82 commit e49f166
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ You can find the Full Documentation of the Webling REST-API at [demo.webling.ch/

## Changelog

##### v1.3.1
* Fixed a bug that prevented response caching from working properly

##### v1.3.0
Support for binary files caching has been added.

Expand All @@ -98,4 +101,4 @@ Support for binary files caching has been added.
* Starting this release, only PHP >= 5.6 is tested and supported

##### v1.2.0
The `Webling\Cache\FileCache` has been marked as deprected and will be removed in the future. Use the more generic `Webling\Cache\Cache` with the `Webling\CacheAdapters\FileCacheAdapter` instead.
The `Webling\Cache\FileCache` has been marked as deprecated and will be removed in the future. Use the more generic `Webling\Cache\Cache` with the `Webling\CacheAdapters\FileCacheAdapter` instead.
4 changes: 2 additions & 2 deletions src/Webling/Cache/Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public function getObject($type, $objectId) {
}
}
}

public function getObjectBinary($type, $objectId, $url, $options = []) {
if ($url) {
$cached = $this->adapter->getObjectBinary($objectId, $url, $options);
Expand Down Expand Up @@ -190,7 +190,7 @@ public function getRoot($type) {
$response = $this->client->get($type);

// only cache 2XX responses
if ($response->getStatusCode() <= 200 && $response->getStatusCode() < 300) {
if ($response->getStatusCode() >= 200 && $response->getStatusCode() < 300) {
$data = $response->getData();
$this->adapter->setRoot($type, $data);
return $data;
Expand Down
2 changes: 1 addition & 1 deletion src/Webling/Cache/FileCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ public function getRoot($type) {
$response = $this->client->get($type);

// only cache 2XX responses
if ($response->getStatusCode() <= 200 && $response->getStatusCode() < 300) {
if ($response->getStatusCode() >= 200 && $response->getStatusCode() < 300) {
$data = $response->getData();
$this->setRootCache($type, $data);
return $data;
Expand Down

0 comments on commit e49f166

Please sign in to comment.