Skip to content

Commit 0cbe4f6

Browse files
committed
Merge branch 'AC-6897' of github.com:magento-cia/magento2ce into cia-2.4.7-beta1-develop-bugfixes-02132023
2 parents a478fc5 + e7ffb9e commit 0cbe4f6

File tree

5 files changed

+156
-4
lines changed

5 files changed

+156
-4
lines changed

app/code/Magento/Catalog/Test/Unit/Pricing/Render/FinalPriceBoxTest.php

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,11 @@
1515
use Magento\Catalog\Pricing\Render\FinalPriceBox;
1616
use Magento\Framework\App\Cache\StateInterface;
1717
use Magento\Framework\App\Config\ScopeConfigInterface;
18+
use Magento\Framework\App\DeploymentConfig;
1819
use Magento\Framework\App\State;
20+
use Magento\Framework\Config\ConfigOptionsListConstants;
1921
use Magento\Framework\Event\Test\Unit\ManagerStub;
22+
use Magento\Framework\ObjectManagerInterface;
2023
use Magento\Framework\Pricing\Amount\AmountInterface;
2124
use Magento\Framework\Pricing\Price\PriceInterface;
2225
use Magento\Framework\Pricing\PriceInfoInterface;
@@ -96,11 +99,27 @@ class FinalPriceBoxTest extends TestCase
9699
*/
97100
private $minimalPriceCalculator;
98101

102+
/**
103+
* @var DeploymentConfig|MockObject
104+
*/
105+
private $deploymentConfig;
106+
107+
/**
108+
* @var ObjectManagerInterface|MockObject
109+
*/
110+
private $objectManagerMock;
111+
99112
/**
100113
* @inheritDoc
114+
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
101115
*/
102116
protected function setUp(): void
103117
{
118+
$this->objectManagerMock = $this->getMockBuilder(ObjectManagerInterface::class)
119+
->disableOriginalConstructor()
120+
->onlyMethods(['get'])
121+
->getMockForAbstractClass();
122+
\Magento\Framework\App\ObjectManager::setInstance($this->objectManagerMock);
104123
$this->product = $this->getMockBuilder(Product::class)
105124
->addMethods(['getCanShowPrice'])
106125
->onlyMethods(['getPriceInfo', 'isSalable', 'getId'])
@@ -183,6 +202,11 @@ protected function setUp(): void
183202
->disableOriginalConstructor()
184203
->getMockForAbstractClass();
185204

205+
$this->deploymentConfig = $this->createPartialMock(
206+
DeploymentConfig::class,
207+
['get']
208+
);
209+
186210
$this->minimalPriceCalculator = $this->getMockForAbstractClass(MinimalPriceCalculatorInterface::class);
187211
$this->object = $objectManager->getObject(
188212
FinalPriceBox::class,
@@ -455,6 +479,15 @@ public function testHidePrice(): void
455479
*/
456480
public function testGetCacheKey(): void
457481
{
482+
$this->objectManagerMock->expects($this->any())
483+
->method('get')
484+
->with(DeploymentConfig::class)
485+
->willReturn($this->deploymentConfig);
486+
487+
$this->deploymentConfig->expects($this->any())
488+
->method('get')
489+
->with(ConfigOptionsListConstants::CONFIG_PATH_CRYPT_KEY)
490+
->willReturn('448198e08af35844a42d3c93c1ef4e03');
458491
$result = $this->object->getCacheKey();
459492
$this->assertStringEndsWith('list-category-page', $result);
460493
}

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,22 @@ class Filter extends Template
6969
/**
7070
* @var bool
7171
* @deprecated SID is not being used as query parameter anymore.
72+
* @see Session ID's in URL
7273
*/
7374
protected $_useSessionInUrl = false;
7475

7576
/**
7677
* @var array
7778
* @deprecated 101.0.4 Use the new Directive Processor interfaces
79+
* @see Directive Processor interfaces
7880
*/
7981
protected $_modifiers = ['nl2br' => ''];
8082

83+
/**
84+
* @var string
85+
*/
86+
private const CACHE_KEY_PREFIX = "EMAIL_FILTER_";
87+
8188
/**
8289
* @var bool
8390
*/
@@ -281,6 +288,7 @@ public function setUseAbsoluteLinks($flag)
281288
* @return $this
282289
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
283290
* @deprecated SID query parameter is not used in URLs anymore.
291+
* @see SessionId's in URL
284292
*/
285293
public function setUseSessionInUrl($flag)
286294
{
@@ -404,6 +412,11 @@ public function blockDirective($construction)
404412
{
405413
$skipParams = ['class', 'id', 'output'];
406414
$blockParameters = $this->getParameters($construction[2]);
415+
416+
if (isset($blockParameters['cache_key'])) {
417+
$blockParameters['cache_key'] = self::CACHE_KEY_PREFIX . $blockParameters['cache_key'];
418+
}
419+
407420
$block = null;
408421

409422
if (isset($blockParameters['class'])) {
@@ -688,6 +701,7 @@ public function varDirective($construction)
688701
* @param string $default assumed modifier if none present
689702
* @return array
690703
* @deprecated 101.0.4 Use the new FilterApplier or Directive Processor interfaces
704+
* @see Directive Processor Interfaces
691705
*/
692706
protected function explodeModifiers($value, $default = null)
693707
{
@@ -707,6 +721,7 @@ protected function explodeModifiers($value, $default = null)
707721
* @param string $modifiers
708722
* @return string
709723
* @deprecated 101.0.4 Use the new FilterApplier or Directive Processor interfaces
724+
* @see Directive Processor Interfaces
710725
*/
711726
protected function applyModifiers($value, $modifiers)
712727
{
@@ -736,6 +751,7 @@ protected function applyModifiers($value, $modifiers)
736751
* @param string $type
737752
* @return string
738753
* @deprecated 101.0.4 Use the new FilterApplier or Directive Processor interfaces
754+
* @see Directive Processor Interfacees
739755
*/
740756
public function modifierEscape($value, $type = 'html')
741757
{

app/code/Magento/Swatches/Test/Unit/Block/Product/Renderer/Listing/ConfigurableTest.php

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,11 @@
2323
use Magento\Framework\App\Config\ScopeConfigInterface;
2424
use Magento\Framework\App\Request\Http;
2525
use Magento\Framework\App\RequestInterface;
26+
use Magento\Framework\App\DeploymentConfig;
27+
use Magento\Framework\Config\ConfigOptionsListConstants;
2628
use Magento\Framework\Json\EncoderInterface;
2729
use Magento\Framework\Model\AbstractModel;
30+
use Magento\Framework\ObjectManagerInterface;
2831
use Magento\Framework\Pricing\PriceCurrencyInterface;
2932
use Magento\Framework\Pricing\PriceInfo\Base;
3033
use Magento\Framework\Stdlib\ArrayUtils;
@@ -95,8 +98,23 @@ class ConfigurableTest extends TestCase
9598
*/
9699
private $request;
97100

101+
/**
102+
* @var ObjectManagerInterface|MockObject
103+
*/
104+
private $objectManagerMock;
105+
106+
/**
107+
* @var DeploymentConfig|MockObject
108+
*/
109+
private $deploymentConfig;
110+
98111
protected function setUp(): void
99112
{
113+
$this->objectManagerMock = $this->getMockBuilder(ObjectManagerInterface::class)
114+
->disableOriginalConstructor()
115+
->onlyMethods(['get'])
116+
->getMockForAbstractClass();
117+
\Magento\Framework\App\ObjectManager::setInstance($this->objectManagerMock);
100118
$this->arrayUtils = $this->createMock(ArrayUtils::class);
101119
$this->jsonEncoder = $this->getMockForAbstractClass(EncoderInterface::class);
102120
$this->helper = $this->createMock(Data::class);
@@ -127,6 +145,16 @@ protected function setUp(): void
127145
$context = $this->getContextMock();
128146
$context->method('getRequest')->willReturn($this->request);
129147

148+
$this->deploymentConfig = $this->createPartialMock(
149+
DeploymentConfig::class,
150+
['get']
151+
);
152+
153+
$this->deploymentConfig->expects($this->any())
154+
->method('get')
155+
->with(ConfigOptionsListConstants::CONFIG_PATH_CRYPT_KEY)
156+
->willReturn('448198e08af35844a42d3c93c1ef4e03');
157+
130158
$objectManagerHelper = new ObjectManager($this);
131159
$this->configurable = $objectManagerHelper->getObject(
132160
ConfigurableRenderer::class,
@@ -146,7 +174,7 @@ protected function setUp(): void
146174
'configurableAttributeData' => $this->configurableAttributeData,
147175
'data' => [],
148176
'variationPrices' => $this->variationPricesMock,
149-
'customerSession' => $customerSession,
177+
'customerSession' => $customerSession
150178
]
151179
);
152180
}
@@ -308,6 +336,10 @@ public function testGetCacheKey()
308336
->willReturn($configurableAttributes);
309337

310338
$this->request->method('toArray')->willReturn($requestParams);
339+
$this->objectManagerMock->expects($this->any())
340+
->method('get')
341+
->with(DeploymentConfig::class)
342+
->willReturn($this->deploymentConfig);
311343
$this->assertStringContainsString(
312344
sha1(json_encode(['color' => 59, 'size' => 1])),
313345
$this->configurable->getCacheKey()

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

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@
77

88
namespace Magento\Framework\View\Element;
99

10+
use Magento\Framework\App\DeploymentConfig;
11+
use Magento\Framework\App\ObjectManager;
1012
use Magento\Framework\Cache\LockGuardedCacheLoader;
13+
use Magento\Framework\Config\ConfigOptionsListConstants;
1114
use Magento\Framework\DataObject\IdentityInterface;
1215

1316
/**
@@ -51,6 +54,7 @@ abstract class AbstractBlock extends \Magento\Framework\DataObject implements Bl
5154
/**
5255
* @var \Magento\Framework\Session\SidResolverInterface
5356
* @deprecated 102.0.5 Not used anymore.
57+
* @see Session Id's In URL
5458
*/
5559
protected $_sidResolver;
5660

@@ -166,6 +170,11 @@ abstract class AbstractBlock extends \Magento\Framework\DataObject implements Bl
166170
*/
167171
protected $_cache;
168172

173+
/**
174+
* @var DeploymentConfig
175+
*/
176+
private $deploymentConfig;
177+
169178
/**
170179
* @var LockGuardedCacheLoader
171180
*/
@@ -199,6 +208,7 @@ public function __construct(
199208
$this->_localeDate = $context->getLocaleDate();
200209
$this->inlineTranslation = $context->getInlineTranslation();
201210
$this->lockQuery = $context->getLockGuardedCacheLoader();
211+
202212
if (isset($data['jsLayout'])) {
203213
$this->jsLayout = $data['jsLayout'];
204214
unset($data['jsLayout']);
@@ -880,6 +890,7 @@ public static function extractModuleName($className)
880890
* @param array|null $allowedTags
881891
* @return string
882892
* @deprecated 103.0.0 Use $escaper directly in templates and in blocks.
893+
* @see Escaper Usage
883894
*/
884895
public function escapeHtml($data, $allowedTags = null)
885896
{
@@ -893,6 +904,7 @@ public function escapeHtml($data, $allowedTags = null)
893904
* @return string
894905
* @since 101.0.0
895906
* @deprecated 103.0.0 Use $escaper directly in templates and in blocks.
907+
* @see Escaper Usage
896908
*/
897909
public function escapeJs($string)
898910
{
@@ -907,6 +919,7 @@ public function escapeJs($string)
907919
* @return string
908920
* @since 101.0.0
909921
* @deprecated 103.0.0 Use $escaper directly in templates and in blocks.
922+
* @see Escaper Usage
910923
*/
911924
public function escapeHtmlAttr($string, $escapeSingleQuote = true)
912925
{
@@ -920,6 +933,7 @@ public function escapeHtmlAttr($string, $escapeSingleQuote = true)
920933
* @return string
921934
* @since 101.0.0
922935
* @deprecated 103.0.0 Use $escaper directly in templates and in blocks.
936+
* @see Escaper Usage
923937
*/
924938
public function escapeCss($string)
925939
{
@@ -947,6 +961,7 @@ public function stripTags($data, $allowableTags = null, $allowHtmlEntities = fal
947961
* @param string $string
948962
* @return string
949963
* @deprecated 103.0.0 Use $escaper directly in templates and in blocks.
964+
* @see Escaper Usage
950965
*/
951966
public function escapeUrl($string)
952967
{
@@ -959,6 +974,7 @@ public function escapeUrl($string)
959974
* @param string $data
960975
* @return string
961976
* @deprecated 101.0.0
977+
* @see Escaper Usage
962978
*/
963979
public function escapeXssInUrl($data)
964980
{
@@ -974,6 +990,7 @@ public function escapeXssInUrl($data)
974990
* @param bool $addSlashes
975991
* @return string
976992
* @deprecated 101.0.0
993+
* @see Escaper Usage
977994
*/
978995
public function escapeQuote($data, $addSlashes = false)
979996
{
@@ -988,6 +1005,7 @@ public function escapeQuote($data, $addSlashes = false)
9881005
*
9891006
* @return string|array
9901007
* @deprecated 101.0.0
1008+
* @see Escaper Usage
9911009
*/
9921010
public function escapeJsQuote($data, $quote = '\'')
9931011
{
@@ -1035,8 +1053,12 @@ public function getCacheKey()
10351053

10361054
$key = array_values($key); // ignore array keys
10371055

1056+
$key[] = (string)$this->getDeploymentConfig()->get(
1057+
ConfigOptionsListConstants::CONFIG_PATH_CRYPT_KEY
1058+
);
1059+
10381060
$key = implode('|', $key);
1039-
$key = sha1($key); // use hashing to hide potentially private data
1061+
$key = hash('sha256', $key); // use hashing to hide potentially private data
10401062
return static::CACHE_KEY_PREFIX . $key;
10411063
}
10421064

@@ -1175,10 +1197,25 @@ public function getVar($name, $module = null)
11751197
*
11761198
* @return bool
11771199
* @deprecated
1200+
* @see https://developer.adobe.com/commerce/php/development/cache/page/private-content
11781201
* @since 103.0.1
11791202
*/
11801203
public function isScopePrivate()
11811204
{
11821205
return $this->_isScopePrivate;
11831206
}
1207+
1208+
/**
1209+
* Get DeploymentConfig
1210+
*
1211+
* @return DeploymentConfig
1212+
*/
1213+
private function getDeploymentConfig() : DeploymentConfig
1214+
{
1215+
if ($this->deploymentConfig === null) {
1216+
$this->deploymentConfig = ObjectManager::getInstance()
1217+
->get(DeploymentConfig::class);
1218+
}
1219+
return $this->deploymentConfig;
1220+
}
11841221
}

0 commit comments

Comments
 (0)