Skip to content

Commit ecd3dee

Browse files
committed
MC-16607: Fix Unrelated Static Test Failures
- improve performance - standardize
1 parent ec75ead commit ecd3dee

File tree

3 files changed

+16
-20
lines changed

3 files changed

+16
-20
lines changed

app/code/Magento/PageBuilder/Plugin/Filter/CustomVarTemplatePlugin.php renamed to app/code/Magento/PageBuilder/Plugin/Filter/CustomVarTemplate.php

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,23 @@
88
namespace Magento\PageBuilder\Plugin\Filter;
99

1010
use Magento\Store\Model\Store;
11+
use Magento\Framework\Escaper;
1112

1213
/**
1314
* Plugin to the template filter to escape custom variable directives
1415
*/
15-
class CustomVarTemplatePlugin
16+
class CustomVarTemplate
1617
{
1718
/**
18-
* @var \Magento\Framework\Escaper
19+
* @var Escaper
1920
*/
2021
private $escaper;
2122

2223
/**
23-
* @param \Magento\Framework\Escaper $escaper
24+
* @param Escaper $escaper
2425
*/
2526
public function __construct(
26-
\Magento\Framework\Escaper $escaper
27+
Escaper $escaper
2728
) {
2829
$this->escaper = $escaper;
2930
}
@@ -32,24 +33,21 @@ public function __construct(
3233
* Determine if custom variable directive's return value needs to be escaped and do so if true
3334
*
3435
* @param \Magento\Framework\Filter\Template $subject
35-
* @param \Closure $proceed
36-
* @param string[] $construction
36+
* @param string $result
3737
* @return string
3838
*/
39-
public function aroundCustomvarDirective(
39+
public function afterCustomvarDirective(
4040
\Magento\Framework\Filter\Template $subject,
41-
\Closure $proceed,
42-
$construction
41+
$result
4342
) {
4443
// Determine the need to escape the return value of observed method.
4544
// Admin context requires store ID of 0; in that context return value should be escaped
4645
$shouldEscape = $subject->getStoreId() !== null && (int) $subject->getStoreId() === Store::DEFAULT_STORE_ID;
4746

48-
if (!$shouldEscape) {
49-
return $proceed($construction);
47+
if ($shouldEscape) {
48+
return $this->escaper->escapeHtml($result);
49+
} else {
50+
return $result;
5051
}
51-
52-
$result = $proceed($construction);
53-
return $this->escaper->escapeHtml($result);
5452
}
5553
}

app/code/Magento/PageBuilder/Plugin/Filter/TemplatePlugin.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,20 +45,18 @@ class TemplatePlugin
4545
* @param \Psr\Log\LoggerInterface $logger
4646
* @param \Magento\Framework\View\ConfigInterface $viewConfig
4747
* @param \Magento\Framework\Math\Random $mathRandom
48-
* @param \Magento\Framework\Serialize\Serializer\Json|null $json
48+
* @param \Magento\Framework\Serialize\Serializer\Json $json
4949
*/
5050
public function __construct(
5151
\Psr\Log\LoggerInterface $logger,
5252
\Magento\Framework\View\ConfigInterface $viewConfig,
5353
\Magento\Framework\Math\Random $mathRandom,
54-
\Magento\Framework\Serialize\Serializer\Json $json = null
54+
\Magento\Framework\Serialize\Serializer\Json $json
5555
) {
5656
$this->logger = $logger;
5757
$this->viewConfig = $viewConfig;
5858
$this->mathRandom = $mathRandom;
59-
$this->json = $json ?? \Magento\Framework\App\ObjectManager::getInstance()->get(
60-
\Magento\Framework\Serialize\Serializer\Json::class
61-
);
59+
$this->json = $json;
6260
}
6361

6462
/**

app/code/Magento/PageBuilder/etc/frontend/di.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@
1111
</type>
1212
<type name="Magento\Framework\Filter\Template">
1313
<plugin name="convertBackgroundImages" type="Magento\PageBuilder\Plugin\Filter\TemplatePlugin"/>
14-
<plugin name="escapeCustomVarDirectives" type="Magento\PageBuilder\Plugin\Filter\CustomVarTemplatePlugin"/>
14+
<plugin name="escapeCustomVarDirectives" type="Magento\PageBuilder\Plugin\Filter\CustomVarTemplate"/>
1515
</type>
1616
</config>

0 commit comments

Comments
 (0)