Skip to content

Commit

Permalink
fixes too long filenames
Browse files Browse the repository at this point in the history
  • Loading branch information
DominikAngerer committed Mar 14, 2017
1 parent 8fba21f commit 0222f7c
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/Storyblok/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ public function getStories($options = array())
$version = 'draft';
}

$key = 'stories/' . serialize($options);
$key = 'stories/' . serialize($this->_prepareOptionsForKey($options));

$this->reCacheOnPublish($key);

Expand Down Expand Up @@ -637,4 +637,22 @@ private function _assignState($response) {
$this->responseBody = $response->httpResponseBody;
$this->responseHeaders = $response->httpResponseHeaders;
}

/**
* prepares to Options for the cache key. Fixes some issues for too long filenames if filecache is used.
*
* @param array $response
* @param string $key
* @param string $version
*/
private function _prepareOptionsForKey($options) {
$prepared = array();
$keyOrder = array();
foreach($options as $key => $value) {
array_push($prepared, $value);
array_push($keyOrder, substr($key, 0, 1));
}
array_push($prepared, join('', $keyOrder));
return $prepared;
}
}

0 comments on commit 0222f7c

Please sign in to comment.