Skip to content

Commit

Permalink
Fix cache generation bug
Browse files Browse the repository at this point in the history
  • Loading branch information
bencroker committed Nov 13, 2024
1 parent 4c89aee commit 702658e
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
# Release Notes for Blitz

## 5.9.4 - 2024-11-13

### Fixed

- Fixed a bug introduced in version 5.9.3 that broke cache generation when “Do not cache URLs with query strings” was selected ([#733](https://github.com/putyourlightson/craft-blitz/issues/733)).

## 5.9.3 - 2024-11-07

### Fixed

- Fixed a bug in which pages with query strings in their URLs could be cached even when “Do not cache URLs with query strings” was selected ([#729](https://github.com/putyourlightson/craft-blitz/issues/729)).

## 5.9.2 - 2024-11-04

### Fixed

- Fixed an error that could occur when generating tagged caches in some cases ([#728](https://github.com/putyourlightson/craft-blitz/issues/728)).
- Fixed a bug in which refresh jobs we re not being created immediately in some console commands.
- Fixed a bug in which refresh jobs were not being created immediately in some console commands.

## 5.9.1 - 2024-10-22

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "putyourlightson/craft-blitz",
"description": "Intelligent static page caching for creating lightning-fast sites.",
"version": "5.9.3",
"version": "5.9.4",
"type": "craft-plugin",
"homepage": "https://putyourlightson.com/plugins/blitz",
"license": "proprietary",
Expand Down
13 changes: 9 additions & 4 deletions src/services/CacheRequestService.php
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ public function getIsCacheableSiteUri(?SiteUriModel $siteUri): bool
}

if (Blitz::$plugin->settings->queryStringCaching == SettingsModel::QUERY_STRINGS_DO_NOT_CACHE_URLS) {
$queryStringParams = $this->getQueryStringParams($siteUri->uri);
$queryStringParams = $this->getQueryStringParamsWithoutToken($siteUri->uri);

if (!empty($queryStringParams)) {
Blitz::$plugin->debug('Page not cached because a query string was provided with the query string caching setting disabled.', [], $url);
Expand Down Expand Up @@ -557,13 +557,18 @@ public function matchesQueryStringParams(int $siteId, string $param, array|strin
}

/**
* Returns the query string params of the URI.
* Returns the query string params of the URI without the token param.
*/
public function getQueryStringParams(string $uri): array
public function getQueryStringParamsWithoutToken(string $uri): array
{
$queryString = parse_url($uri, PHP_URL_QUERY) ?: '';
parse_str($queryString, $queryStringParams);

$tokenParam = Craft::$app->getConfig()->getGeneral()->tokenParam;
if (isset($queryStringParams[$tokenParam])) {
unset($queryStringParams[$tokenParam]);
}

return $queryStringParams;
}

Expand All @@ -576,7 +581,7 @@ public function getAllowedQueryString(int $siteId, string $uri): string
return $this->allowedQueryStrings[$siteId][$uri];
}

$queryStringParams = $this->getQueryStringParams($uri);
$queryStringParams = $this->getQueryStringParamsWithoutToken($uri);

if (!$this->getIsCachedInclude($uri)) {
foreach ($queryStringParams as $key => $value) {
Expand Down

0 comments on commit 702658e

Please sign in to comment.