Skip to content

Commit 8c28b95

Browse files
authored
Merge branch '2.4-develop' into fix-39756
2 parents 86ba2d7 + e4a14e0 commit 8c28b95

File tree

5 files changed

+108
-93
lines changed

5 files changed

+108
-93
lines changed

app/code/Magento/Checkout/view/frontend/templates/cart/item/default.phtml

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
// phpcs:disable Generic.Files.LineLength
99

1010
/** @var $block \Magento\Checkout\Block\Cart\Item\Renderer */
11+
/** @var \Magento\Framework\Escaper $escaper */
1112

1213
$_item = $block->getItem();
1314
$product = $_item->getProduct();
@@ -18,10 +19,10 @@ $canApplyMsrp = $helper->isShowBeforeOrderConfirm($product) && $helper->isMinima
1819
?>
1920
<tbody class="cart item">
2021
<tr class="item-info">
21-
<td data-th="<?= $block->escapeHtml(__('Item')) ?>" class="col item">
22+
<td data-th="<?= $escaper->escapeHtml(__('Item')) ?>" class="col item">
2223
<?php if ($block->hasProductUrl()): ?>
23-
<a href="<?= $block->escapeUrl($block->getProductUrl()) ?>"
24-
title="<?= $block->escapeHtml($block->getProductName()) ?>"
24+
<a href="<?= $escaper->escapeUrl($block->getProductUrl()) ?>"
25+
title="<?= $escaper->escapeHtml($block->getProductName()) ?>"
2526
tabindex="-1"
2627
class="product-item-photo">
2728
<?php else: ?>
@@ -36,30 +37,30 @@ $canApplyMsrp = $helper->isShowBeforeOrderConfirm($product) && $helper->isMinima
3637
<div class="product-item-details">
3738
<strong class="product-item-name">
3839
<?php if ($block->hasProductUrl()): ?>
39-
<a href="<?= $block->escapeUrl($block->getProductUrl()) ?>"><?= $block->escapeHtml($block->getProductName()) ?></a>
40+
<a href="<?= $escaper->escapeUrl($block->getProductUrl()) ?>"><?= $escaper->escapeHtml($block->getProductName()) ?></a>
4041
<?php else: ?>
41-
<?= $block->escapeHtml($block->getProductName()) ?>
42+
<?= $escaper->escapeHtml($block->getProductName()) ?>
4243
<?php endif; ?>
4344
</strong>
4445
<?php if ($_options = $block->getOptionList()): ?>
4546
<dl class="item-options">
4647
<?php foreach ($_options as $_option): ?>
4748
<?php $_formatedOptionValue = $block->getFormatedOptionValue($_option) ?>
48-
<dt><?= $block->escapeHtml($_option['label']) ?></dt>
49+
<dt><?= $escaper->escapeHtml($_option['label']) ?></dt>
4950
<dd>
5051
<?php if (isset($_formatedOptionValue['full_view'])): ?>
51-
<?= $block->escapeHtml($_formatedOptionValue['full_view'], ['span', 'a']) ?>
52+
<?= $escaper->escapeHtml($_formatedOptionValue['full_view'], ['span', 'a']) ?>
5253
<?php else: ?>
53-
<?= $block->escapeHtml($_formatedOptionValue['value'], ['span', 'a']) ?>
54+
<?= $escaper->escapeHtml($_formatedOptionValue['value'], ['span', 'a']) ?>
5455
<?php endif; ?>
5556
</dd>
5657
<?php endforeach; ?>
5758
</dl>
5859
<?php endif; ?>
5960
<?php if ($messages = $block->getMessages()): ?>
6061
<?php foreach ($messages as $message): ?>
61-
<div class= "cart item message <?= $block->escapeHtmlAttr($message['type']) ?>">
62-
<div><?= $block->escapeHtml($message['text']) ?></div>
62+
<div class="cart item message <?= $escaper->escapeHtmlAttr($message['type']) ?>">
63+
<div><?= $escaper->escapeHtml($message['text']) ?></div>
6364
</div>
6465
<?php endforeach; ?>
6566
<?php endif; ?>
@@ -71,53 +72,53 @@ $canApplyMsrp = $helper->isShowBeforeOrderConfirm($product) && $helper->isMinima
7172
</td>
7273

7374
<?php if ($canApplyMsrp): ?>
74-
<td class="col msrp" data-th="<?= $block->escapeHtml(__('Price')) ?>">
75+
<td class="col msrp" data-th="<?= $escaper->escapeHtml(__('Price')) ?>">
7576
<span class="pricing msrp">
76-
<span class="msrp notice"><?= $block->escapeHtml(__('See price before order confirmation.')) ?></span>
77+
<span class="msrp notice"><?= $escaper->escapeHtml(__('See price before order confirmation.')) ?></span>
7778
<?php $helpLinkId = 'cart-msrp-help-' . $_item->getId(); ?>
7879
<a href="#" class="action help map"
79-
id="<?= ($block->escapeHtmlAttr($helpLinkId)) ?>"
80+
id="<?= ($escaper->escapeHtmlAttr($helpLinkId)) ?>"
8081
data-mage-init='{"addToCart":{
8182
"origin": "info",
82-
"helpLinkId": "#<?= $block->escapeJs($block->escapeHtml($helpLinkId)) ?>",
83-
"productName": "<?= $block->escapeJs($block->escapeHtml($product->getName())) ?>",
83+
"helpLinkId": "#<?= $escaper->escapeJs($escaper->escapeHtml($helpLinkId)) ?>",
84+
"productName": "<?= $escaper->escapeJs($escaper->escapeHtml($product->getName())) ?>",
8485
"showAddToCart": false
8586
}
8687
}'
8788
>
88-
<span><?= $block->escapeHtml(__("What's this?")) ?></span>
89+
<span><?= $escaper->escapeHtml(__("What's this?")) ?></span>
8990
</a>
9091
</span>
9192
</td>
9293
<?php else: ?>
93-
<td class="col price" data-th="<?= $block->escapeHtml(__('Price')) ?>">
94+
<td class="col price" data-th="<?= $escaper->escapeHtml(__('Price')) ?>">
9495
<?= $block->getUnitPriceHtml($_item) ?>
9596
</td>
9697
<?php endif; ?>
97-
<td class="col qty" data-th="<?= $block->escapeHtml(__('Qty')) ?>">
98+
<td class="col qty" data-th="<?= $escaper->escapeHtml(__('Qty')) ?>">
9899
<div class="field qty">
99100
<div class="control qty">
100-
<label for="cart-<?= $block->escapeHtmlAttr($_item->getId()) ?>-qty">
101-
<span class="label"><?= $block->escapeHtml(__('Qty')) ?></span>
102-
<input id="cart-<?= $block->escapeHtmlAttr($_item->getId()) ?>-qty"
103-
name="cart[<?= $block->escapeHtmlAttr($_item->getId()) ?>][qty]"
104-
data-cart-item-id="<?= $block->escapeHtmlAttr($_item->getSku()) ?>"
105-
value="<?= $block->escapeHtmlAttr($block->getQty()) ?>"
101+
<label for="cart-<?= $escaper->escapeHtmlAttr($_item->getId()) ?>-qty">
102+
<span class="label"><?= $escaper->escapeHtml(__('Qty')) ?></span>
103+
<input id="cart-<?= $escaper->escapeHtmlAttr($_item->getId()) ?>-qty"
104+
name="cart[<?= $escaper->escapeHtmlAttr($_item->getId()) ?>][qty]"
105+
data-cart-item-id="<?= $escaper->escapeHtmlAttr($_item->getSku()) ?>"
106+
value="<?= $escaper->escapeHtmlAttr($block->getQty()) ?>"
106107
type="number"
107108
min="0"
108109
size="4"
109110
step="any"
110-
title="<?= $block->escapeHtmlAttr(__('Qty')) ?>"
111+
title="<?= $escaper->escapeHtmlAttr(__('Qty')) ?>"
111112
class="input-text qty"
112113
data-validate="{required:true,'validate-greater-than-zero':true}"
113-
data-item-qty="<?= $block->escapeHtmlAttr($block->getQty()) ?>"
114+
data-item-qty="<?= $escaper->escapeHtmlAttr($block->getQty()) ?>"
114115
data-role="cart-item-qty"/>
115116
</label>
116117
</div>
117118
</div>
118119
</td>
119120

120-
<td class="col subtotal" data-th="<?= $block->escapeHtml(__('Subtotal')) ?>">
121+
<td class="col subtotal" data-th="<?= $escaper->escapeHtml(__('Subtotal')) ?>">
121122
<?php if ($canApplyMsrp): ?>
122123
<span class="cart msrp subtotal">--</span>
123124
<?php else: ?>

app/code/Magento/Customer/Model/AccountManagement.php

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -967,7 +967,8 @@ public function createAccountWithPasswordHash(CustomerInterface $customer, $hash
967967
}
968968
$this->customerRegistry->remove($customer->getId());
969969
} catch (InputException $e) {
970-
$this->customerRepository->delete($customer);
970+
$this->deleteCustomerInSecureArea($customer);
971+
971972
throw $e;
972973
}
973974
$customer = $this->customerRepository->getById($customer->getId());
@@ -1678,4 +1679,23 @@ private function isAddressAllowedForWebsite(AddressInterface $address, $storeId)
16781679

16791680
return in_array($address->getCountryId(), $allowedCountries);
16801681
}
1682+
1683+
/**
1684+
* Set isSecureArea to true, then delete the customer and revert isSecureArea to original value
1685+
*
1686+
* @param CustomerInterface $customer
1687+
* @return void
1688+
* @throws LocalizedException
1689+
*/
1690+
private function deleteCustomerInSecureArea(CustomerInterface $customer): void
1691+
{
1692+
$originalValue = $this->registry->registry('isSecureArea');
1693+
$this->registry->unregister('isSecureArea');
1694+
$this->registry->register('isSecureArea', true);
1695+
1696+
$this->customerRepository->delete($customer);
1697+
1698+
$this->registry->unregister('isSecureArea');
1699+
$this->registry->register('isSecureArea', $originalValue);
1700+
}
16811701
}

app/code/Magento/Quote/Model/Quote/Item/AbstractItem.php

Lines changed: 28 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,14 @@
33
* Copyright 2011 Adobe
44
* All Rights Reserved.
55
*/
6+
67
namespace Magento\Quote\Model\Quote\Item;
78

8-
use Magento\Quote\Model\Quote\Item;
9+
use Magento\Catalog\Model\Product\Configuration\Item\ItemInterface;
10+
use Magento\Catalog\Model\Product\Configuration\Item\Option\OptionInterface;
911
use Magento\Framework\Api\AttributeValueFactory;
12+
use Magento\Framework\Model\AbstractExtensibleModel;
13+
use Magento\Quote\Model\Quote\Item;
1014

1115
/**
1216
* Quote item abstract model
@@ -25,15 +29,15 @@
2529
* @method float getBaseDiscountAmount()
2630
* @method \Magento\Quote\Model\Quote\Item\AbstractItem setBaseDiscountAmount(float $amount)
2731
* @method float getDiscountPercent()
28-
* @method \Magento\Quote\Model\Quote\Item\AbstractItem setDiscountPercent()
32+
* @method \Magento\Quote\Model\Quote\Item\AbstractItem setDiscountPercent(float $percent)
2933
* @method float getOriginalDiscountAmount()
30-
* @method \Magento\Quote\Model\Quote\Item\AbstractItem setOriginalDiscountAmount()
34+
* @method \Magento\Quote\Model\Quote\Item\AbstractItem setOriginalDiscountAmount(float $amount)
3135
* @method float getBaseOriginalDiscountAmount()
32-
* @method \Magento\Quote\Model\Quote\Item\AbstractItem setBaseOriginalDiscountAmount()
36+
* @method \Magento\Quote\Model\Quote\Item\AbstractItem setBaseOriginalDiscountAmount(float $amount)
3337
* @method float getDiscountCalculationPrice()
34-
* @method \Magento\Quote\Model\Quote\Item\AbstractItem setDiscountCalculationPrice()
38+
* @method \Magento\Quote\Model\Quote\Item\AbstractItem setDiscountCalculationPrice(float $amount)
3539
* @method float getBaseDiscountCalculationPrice()
36-
* @method \Magento\Quote\Model\Quote\Item\AbstractItem setBaseDiscountCalculationPrice($price)
40+
* @method \Magento\Quote\Model\Quote\Item\AbstractItem setBaseDiscountCalculationPrice(float $price)
3741
* @method int[] getAppliedRuleIds()
3842
* @method \Magento\Quote\Model\Quote\Item\AbstractItem setAppliedRuleIds(array $ruleIds)
3943
* @method float getBaseTaxAmount()
@@ -48,8 +52,7 @@
4852
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
4953
* @since 100.0.2
5054
*/
51-
abstract class AbstractItem extends \Magento\Framework\Model\AbstractExtensibleModel implements
52-
\Magento\Catalog\Model\Product\Configuration\Item\ItemInterface
55+
abstract class AbstractItem extends AbstractExtensibleModel implements ItemInterface
5356
{
5457
/**
5558
* @var Item|null
@@ -69,7 +72,7 @@ abstract class AbstractItem extends \Magento\Framework\Model\AbstractExtensibleM
6972
/**
7073
* List of custom options
7174
*
72-
* @var array
75+
* @var OptionInterface[]
7376
*/
7477
protected $_optionsByCode;
7578

@@ -188,7 +191,7 @@ public function beforeSave()
188191
/**
189192
* Set parent item
190193
*
191-
* @param Item $parentItem
194+
* @param Item $parentItem
192195
* @return $this
193196
*/
194197
public function setParentItem($parentItem)
@@ -223,7 +226,7 @@ public function getChildren()
223226
/**
224227
* Add child item
225228
*
226-
* @param \Magento\Quote\Model\Quote\Item\AbstractItem $child
229+
* @param \Magento\Quote\Model\Quote\Item\AbstractItem $child
227230
* @return $this
228231
*/
229232
public function addChild($child)
@@ -236,7 +239,7 @@ public function addChild($child)
236239
/**
237240
* Adds message(s) for quote item. Duplicated messages are not added.
238241
*
239-
* @param mixed $messages
242+
* @param mixed $messages
240243
* @return $this
241244
*/
242245
public function setMessage($messages)
@@ -256,7 +259,7 @@ public function setMessage($messages)
256259
/**
257260
* Add message of quote item to array of messages
258261
*
259-
* @param mixed $message
262+
* @param string $message
260263
* @return $this
261264
*/
262265
public function addMessage($message)
@@ -268,8 +271,8 @@ public function addMessage($message)
268271
/**
269272
* Get messages array of quote item
270273
*
271-
* @param bool $string flag for converting messages to string
272-
* @return array|string
274+
* @param bool $string flag for converting messages to string
275+
* @return array|string
273276
*/
274277
public function getMessage($string = true)
275278
{
@@ -625,18 +628,12 @@ public function __clone()
625628
*/
626629
public function isChildrenCalculated()
627630
{
628-
if ($this->getParentItem()) {
629-
$calculate = $this->getParentItem()->getProduct()->getPriceType();
630-
} else {
631-
$calculate = $this->getProduct()->getPriceType();
632-
}
631+
$calculate = $this->getParentItem()
632+
? $this->getParentItem()->getProduct()->getPriceType()
633+
: $this->getProduct()->getPriceType();
633634

634-
if (null !== $calculate &&
635-
(int)$calculate === \Magento\Catalog\Model\Product\Type\AbstractType::CALCULATE_CHILD
636-
) {
637-
return true;
638-
}
639-
return false;
635+
return $calculate !== null
636+
&& (int)$calculate === \Magento\Catalog\Model\Product\Type\AbstractType::CALCULATE_CHILD;
640637
}
641638

642639
/**
@@ -649,18 +646,12 @@ public function isChildrenCalculated()
649646
*/
650647
public function isShipSeparately()
651648
{
652-
if ($this->getParentItem()) {
653-
$shipmentType = $this->getParentItem()->getProduct()->getShipmentType();
654-
} else {
655-
$shipmentType = $this->getProduct()->getShipmentType();
656-
}
649+
$shipmentType = $this->getParentItem()
650+
? $this->getParentItem()->getProduct()->getShipmentType()
651+
: $this->getProduct()->getShipmentType();
657652

658-
if (null !== $shipmentType &&
659-
(int)$shipmentType === \Magento\Catalog\Model\Product\Type\AbstractType::SHIPMENT_SEPARATELY
660-
) {
661-
return true;
662-
}
663-
return false;
653+
return null !== $shipmentType &&
654+
(int)$shipmentType === \Magento\Catalog\Model\Product\Type\AbstractType::SHIPMENT_SEPARATELY;
664655
}
665656

666657
/**

composer.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,10 @@
387387
"exclude-from-classmap": [
388388
"**/dev/**",
389389
"**/update/**",
390-
"*/*/Test/**/*Test"
390+
"**/Test/Fixture/**",
391+
"**/Test/Integration/**",
392+
"**/Test/Mftf/**",
393+
"**/Test/Unit/**"
391394
]
392395
},
393396
"autoload-dev": {

0 commit comments

Comments
 (0)