Skip to content

Commit

Permalink
Fix tracking of eager-loaded block elements
Browse files Browse the repository at this point in the history
  • Loading branch information
bencroker committed Feb 12, 2024
1 parent 596508e commit 65efb05
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 5 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

## 4.11.1 - 2024-02-12

### Fixed

- Fixed the tracking of non-cacheable block elements when eager-loaded.

## 4.11.0 - 2024-02-12

### Added
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.0",
"version": "4.11.1",
"type": "craft-plugin",
"homepage": "https://putyourlightson.com/plugins/blitz",
"license": "proprietary",
Expand Down
2 changes: 1 addition & 1 deletion src/Blitz.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public static function config(): array
/**
* @inheritdoc
*/
public string $schemaVersion = '4.10.1';
public string $schemaVersion = '4.11.1';

/**
* @inheritdoc
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

namespace putyourlightson\blitz\migrations;

use craft\db\Migration;

class m240212_120000_clear_out_legacy_cached_element_types extends Migration
{
/**
* @inheritdoc
*/
public function safeUp(): bool
{
$migration = new m240110_120000_clear_out_legacy_cached_element_types();
$migration->safeUp();

return true;
}

/**
* @inheritdoc
*/
public function safeDown(): bool
{
echo self::class . " cannot be reverted.\n";

return true;
}
}
9 changes: 6 additions & 3 deletions src/services/GenerateCacheService.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,12 @@ function(EagerLoadElementsEvent $event) {
/** @var ElementInterface|string $elementType */
$elementType = $event->elementType;
$map = $elementType::eagerLoadingMap($event->elements, $plan->handle);
if (!empty($map['map'])) {
foreach ($map['map'] as $mapping) {
$this->generateData->addElementId($mapping['target']);

if (is_array($map)) {
if ($this->_shouldTrackElementsOfType($map['elementType'])) {
foreach ($map['map'] as $mapping) {
$this->generateData->addElementId($mapping['target']);
}
}
}
}
Expand Down

0 comments on commit 65efb05

Please sign in to comment.