Skip to content

Commit

Permalink
Use column aliases in inner joins
Browse files Browse the repository at this point in the history
  • Loading branch information
bencroker committed Aug 5, 2024
1 parent 39c1af2 commit be9008b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 12 deletions.
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

## 5.6.2 - 2024-08-05

### Fixed

- Fixed a bug that could throw an exception when viewing tracked entries in the Blitz Diagnostics utility when the database tables have a prefix.

## 5.6.1 - 2024-08-05

### 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": "5.6.1",
"version": "5.6.2",
"type": "craft-plugin",
"homepage": "https://putyourlightson.com/plugins/blitz",
"license": "proprietary",
Expand Down
22 changes: 11 additions & 11 deletions src/helpers/DiagnosticsHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,8 @@ public static function getElementsQuery(int $siteId, string $elementType, ?int $
{
$condition = [
'and',
[CacheRecord::tableName() . '.siteId' => $siteId],
[Table::ELEMENTS_SITES . '.siteId' => $siteId],
['caches.siteId' => $siteId],
['elementsites.siteId' => $siteId],
['type' => $elementType],
['elements_owners.ownerId' => null],
];
Expand All @@ -264,9 +264,9 @@ public static function getElementsQuery(int $siteId, string $elementType, ?int $
return ElementCacheRecord::find()
->from(['elementcaches' => ElementCacheRecord::tableName()])
->select(['elementcaches.elementId', 'elementexpirydates.expiryDate', 'count(*) as count', 'title'])
->innerJoinWith('cache')
->innerJoinWith('element')
->innerJoinWith('elementSite')
->innerJoinWith('cache caches')
->innerJoinWith('element elements')
->innerJoinWith('elementSite elementsites')
->leftJoin(['elementexpirydates' => ElementExpiryDateRecord::tableName()], '[[elementexpirydates.elementId]] = [[elementcaches.elementId]]')
->leftJoin(['elements_owners' => Table::ELEMENTS_OWNERS], '[[elementcaches.elementId]] = [[elements_owners.elementId]]')
->where($condition)
Expand All @@ -278,8 +278,8 @@ public static function getNestedElementsQuery(int $siteId, string $elementType,
{
$condition = [
'and',
[CacheRecord::tableName() . '.siteId' => $siteId],
[Table::ELEMENTS_SITES . '.siteId' => $siteId],
['caches.siteId' => $siteId],
['elementsites.siteId' => $siteId],
['type' => $elementType],
['not', ['elements_owners.ownerId' => null]],
];
Expand All @@ -290,10 +290,10 @@ public static function getNestedElementsQuery(int $siteId, string $elementType,

return ElementCacheRecord::find()
->from(['elementcaches' => ElementCacheRecord::tableName()])
->select(['elementcaches.elementId', 'elementexpirydates.expiryDate', 'count(*) as count', Table::ELEMENTS_SITES . '.title', 'sortOrder', 'ownerTitle' => 'elements_owners_sites.title', 'entryType' => 'entrytypes.name'])
->innerJoinWith('cache')
->innerJoinWith('element')
->innerJoinWith('elementSite')
->select(['elementcaches.elementId', 'elementexpirydates.expiryDate', 'count(*) as count', 'elementsites.title', 'sortOrder', 'ownerTitle' => 'elements_owners_sites.title', 'entryType' => 'entrytypes.name'])
->innerJoinWith('cache caches')
->innerJoinWith('element elements')
->innerJoinWith('elementSite elementsites')
->leftJoin(['elementexpirydates' => ElementExpiryDateRecord::tableName()], '[[elementexpirydates.elementId]] = [[elementcaches.elementId]]')
->leftJoin(['elements_owners' => Table::ELEMENTS_OWNERS], '[[elementcaches.elementId]] = [[elements_owners.elementId]]')
->leftJoin(['elements_owners_sites' => Table::ELEMENTS_SITES], '[[elements_owners.ownerId]] = [[elements_owners_sites.elementId]]')
Expand Down

0 comments on commit be9008b

Please sign in to comment.