Skip to content

Commit 15a05f8

Browse files
AC-6897 template caching improvements
1 parent 150d432 commit 15a05f8

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

app/code/Magento/Email/Model/Template/Filter.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,11 @@ class Filter extends Template
7878
*/
7979
protected $_modifiers = ['nl2br' => ''];
8080

81+
/**
82+
* @var string
83+
*/
84+
private const CACHE_KEY_PREFIX = "EMAIL_FILTER_";
85+
8186
/**
8287
* @var bool
8388
*/
@@ -404,6 +409,11 @@ public function blockDirective($construction)
404409
{
405410
$skipParams = ['class', 'id', 'output'];
406411
$blockParameters = $this->getParameters($construction[2]);
412+
413+
if ($blockParameters['cache_key']) {
414+
$blockParameters['cache_key'] = self::CACHE_KEY_PREFIX . $blockParameters['cache_key'];
415+
}
416+
407417
$block = null;
408418

409419
if (isset($blockParameters['class'])) {

lib/internal/Magento/Framework/View/Element/AbstractBlock.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1052,7 +1052,7 @@ public function getCacheKey()
10521052
$key[] = (string)$this->deploymentConfig->get(ConfigOptionsListConstants::CONFIG_PATH_CRYPT_KEY);
10531053

10541054
$key = implode('|', $key);
1055-
$key = sha1($key); // use hashing to hide potentially private data
1055+
$key = hash('sha256', $key); // use hashing to hide potentially private data
10561056
return static::CACHE_KEY_PREFIX . $key;
10571057
}
10581058

lib/internal/Magento/Framework/View/Test/Unit/Element/AbstractBlockTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ public function testGetCacheKeyByName()
246246
$nameInLayout = 'testBlock';
247247
$this->block->setNameInLayout($nameInLayout);
248248
$encryptionKey = $this->deploymentConfig->get(ConfigOptionsListConstants::CONFIG_PATH_CRYPT_KEY);
249-
$cacheKey = sha1($nameInLayout . '|' . $encryptionKey);
249+
$cacheKey = hash('sha256', $nameInLayout . '|' . $encryptionKey);
250250
$this->assertEquals(AbstractBlock::CACHE_KEY_PREFIX . $cacheKey, $this->block->getCacheKey());
251251
}
252252

0 commit comments

Comments
 (0)