diff --git a/CHANGELOG.md b/CHANGELOG.md index 3b928306..4fb1ec6e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/composer.json b/composer.json index ff4ecdc9..c8b4b329 100644 --- a/composer.json +++ b/composer.json @@ -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", diff --git a/src/helpers/ElementQueryHelper.php b/src/helpers/ElementQueryHelper.php index 6de705d2..8b92d6a0 100644 --- a/src/helpers/ElementQueryHelper.php +++ b/src/helpers/ElementQueryHelper.php @@ -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; @@ -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 { @@ -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: diff --git a/src/services/GenerateCacheService.php b/src/services/GenerateCacheService.php index 9a3adbe5..68eb76f9 100755 --- a/src/services/GenerateCacheService.php +++ b/src/services/GenerateCacheService.php @@ -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);