Skip to content

Commit

Permalink
Don't sort router parameter for caching purpose
Browse files Browse the repository at this point in the history
Otherwise the order of the parameters given to the router is not
consitent with the one that the API user gives.

Signed-off-by: Carl Schwan <carl@carlschwan.eu>
  • Loading branch information
CarlSchwan committed Apr 19, 2022
1 parent e21fb22 commit 5d82106
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/private/Route/CachingRouter.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,9 @@ public function __construct($cache, LoggerInterface $logger) {
* @return string
*/
public function generate($name, $parameters = [], $absolute = false) {
asort($parameters);
$key = $this->context->getHost() . '#' . $this->context->getBaseUrl() . $name . sha1(json_encode($parameters)) . (int)$absolute;
$sortedParameters = $parameters;
asort($sortedParameters);
$key = $this->context->getHost() . '#' . $this->context->getBaseUrl() . $name . sha1(json_encode($sortedParameters)) . (int)$absolute;
$cachedKey = $this->cache->get($key);
if ($cachedKey) {
return $cachedKey;
Expand Down

0 comments on commit 5d82106

Please sign in to comment.