Skip to content

Commit

Permalink
Don’t track asset queries with filenames
Browse files Browse the repository at this point in the history
  • Loading branch information
bencroker committed Feb 16, 2024
1 parent 65efb05 commit 6d44caa
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 1 deletion.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Release Notes for Blitz

## 4.11.2 - Unreleased

### Changed

- Asset queries containing filenames are no longer tracked.

## 4.11.1 - 2024-02-12

### Fixed
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": "4.11.1",
"version": "4.11.2",
"type": "craft-plugin",
"homepage": "https://putyourlightson.com/plugins/blitz",
"license": "proprietary",
Expand Down
17 changes: 17 additions & 0 deletions src/helpers/ElementQueryHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Craft;
use craft\base\ElementInterface;
use craft\behaviors\CustomFieldBehavior;
use craft\elements\db\AssetQuery;
use craft\elements\db\ElementQuery;
use craft\elements\db\ElementQueryInterface;
use craft\elements\db\EntryQuery;
Expand Down Expand Up @@ -326,6 +327,8 @@ public static function isDraftOrRevisionQuery(ElementQuery $elementQuery): bool

/**
* Returns whether the element query is an entry query for “single” sections.
*
* @since 4.11.0
*/
public static function isEntryQueryForSingleSections(ElementQuery $elementQuery): bool
{
Expand All @@ -351,6 +354,20 @@ public static function isEntryQueryForSingleSections(ElementQuery $elementQuery)
return true;
}

/**
* Returns whether the element query is an asset query with a filename.
*
* @since 4.11.2
*/
public static function isAssetQueryWithFilename(ElementQuery $elementQuery): bool
{
if (!($elementQuery instanceof AssetQuery)) {
return false;
}

return $elementQuery->filename !== null;
}

/**
* Returns whether the element query is a relation field query.
* For example:
Expand Down
5 changes: 5 additions & 0 deletions src/services/GenerateCacheService.php
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,11 @@ public function addElementQuery(ElementQuery $elementQuery): void
return;
}

// Don’t proceed if this is an asset query with a filename
if (ElementQueryHelper::isAssetQueryWithFilename($elementQuery)) {
return;
}

// Don’t proceed if this is a relation field query
if (ElementQueryHelper::isRelationFieldQuery($elementQuery)) {
$this->_addRelatedElementIds($elementQuery);
Expand Down

0 comments on commit 6d44caa

Please sign in to comment.