Skip to content

Commit fbbb342

Browse files
committed
Merge branch '2.3-develop' of https://github.com/magento/magento2ce into MAGETWO-98825
2 parents 371c9ff + 6e534ad commit fbbb342

File tree

94 files changed

+1301
-316
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

94 files changed

+1301
-316
lines changed

app/code/Magento/AdminNotification/Model/Feed.php

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ class Feed extends \Magento\Framework\Model\AbstractModel
2525

2626
const XML_LAST_UPDATE_PATH = 'system/adminnotification/last_update';
2727

28+
/**
29+
* @var \Magento\Framework\Escaper
30+
*/
31+
private $escaper;
32+
2833
/**
2934
* Feed url
3035
*
@@ -77,6 +82,7 @@ class Feed extends \Magento\Framework\Model\AbstractModel
7782
* @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource
7883
* @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection
7984
* @param array $data
85+
* @param \Magento\Framework\Escaper|null $escaper
8086
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
8187
*/
8288
public function __construct(
@@ -90,21 +96,26 @@ public function __construct(
9096
\Magento\Framework\UrlInterface $urlBuilder,
9197
\Magento\Framework\Model\ResourceModel\AbstractResource $resource = null,
9298
\Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null,
93-
array $data = []
99+
array $data = [],
100+
\Magento\Framework\Escaper $escaper = null
94101
) {
95102
parent::__construct($context, $registry, $resource, $resourceCollection, $data);
96-
$this->_backendConfig = $backendConfig;
97-
$this->_inboxFactory = $inboxFactory;
98-
$this->curlFactory = $curlFactory;
103+
$this->_backendConfig = $backendConfig;
104+
$this->_inboxFactory = $inboxFactory;
105+
$this->curlFactory = $curlFactory;
99106
$this->_deploymentConfig = $deploymentConfig;
100-
$this->productMetadata = $productMetadata;
101-
$this->urlBuilder = $urlBuilder;
107+
$this->productMetadata = $productMetadata;
108+
$this->urlBuilder = $urlBuilder;
109+
$this->escaper = $escaper ?? \Magento\Framework\App\ObjectManager::getInstance()->get(
110+
\Magento\Framework\Escaper::class
111+
);
102112
}
103113

104114
/**
105115
* Init model
106116
*
107117
* @return void
118+
* phpcs:disable Magento2.CodeAnalysis.EmptyBlock
108119
*/
109120
protected function _construct()
110121
{
@@ -252,6 +263,6 @@ public function getFeedXml()
252263
*/
253264
private function escapeString(\SimpleXMLElement $data)
254265
{
255-
return htmlspecialchars((string)$data);
266+
return $this->escaper->escapeHtml((string)$data);
256267
}
257268
}

app/code/Magento/Bundle/view/frontend/templates/sales/order/creditmemo/items/renderer.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
</td>
6868
<td class="col discount" data-th="<?= $block->escapeHtml(__('Discount Amount')) ?>">
6969
<?php if ($block->canShowPriceInfo($_item)) : ?>
70-
<?= $block->escapeHtml($block->getOrder()->formatPrice(-$_item->getDiscountAmount())) ?>
70+
<?= $block->escapeHtml($block->getOrder()->formatPrice(-$_item->getDiscountAmount()), ['span']) ?>
7171
<?php else : ?>
7272
&nbsp;
7373
<?php endif; ?>

app/code/Magento/Catalog/Block/Adminhtml/Product/Edit.php

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,16 @@
1212
*/
1313
namespace Magento\Catalog\Block\Adminhtml\Product;
1414

15+
/**
16+
* Class Edit
17+
*/
1518
class Edit extends \Magento\Backend\Block\Widget
1619
{
20+
/**
21+
* @var \Magento\Framework\Escaper
22+
*/
23+
private $escaper;
24+
1725
/**
1826
* @var string
1927
*/
@@ -47,6 +55,7 @@ class Edit extends \Magento\Backend\Block\Widget
4755
* @param \Magento\Eav\Model\Entity\Attribute\SetFactory $attributeSetFactory
4856
* @param \Magento\Framework\Registry $registry
4957
* @param \Magento\Catalog\Helper\Product $productHelper
58+
* @param \Magento\Framework\Escaper $escaper
5059
* @param array $data
5160
*/
5261
public function __construct(
@@ -55,16 +64,20 @@ public function __construct(
5564
\Magento\Eav\Model\Entity\Attribute\SetFactory $attributeSetFactory,
5665
\Magento\Framework\Registry $registry,
5766
\Magento\Catalog\Helper\Product $productHelper,
67+
\Magento\Framework\Escaper $escaper,
5868
array $data = []
5969
) {
6070
$this->_productHelper = $productHelper;
6171
$this->_attributeSetFactory = $attributeSetFactory;
6272
$this->_coreRegistry = $registry;
6373
$this->jsonEncoder = $jsonEncoder;
74+
$this->escaper = $escaper;
6475
parent::__construct($context, $data);
6576
}
6677

6778
/**
79+
* Edit Product constructor
80+
*
6881
* @return void
6982
*/
7083
protected function _construct()
@@ -144,6 +157,8 @@ protected function _prepareLayout()
144157
}
145158

146159
/**
160+
* Retrieve back button html
161+
*
147162
* @return string
148163
*/
149164
public function getBackButtonHtml()
@@ -152,6 +167,8 @@ public function getBackButtonHtml()
152167
}
153168

154169
/**
170+
* Retrieve cancel button html
171+
*
155172
* @return string
156173
*/
157174
public function getCancelButtonHtml()
@@ -160,6 +177,8 @@ public function getCancelButtonHtml()
160177
}
161178

162179
/**
180+
* Retrieve save button html
181+
*
163182
* @return string
164183
*/
165184
public function getSaveButtonHtml()
@@ -168,6 +187,8 @@ public function getSaveButtonHtml()
168187
}
169188

170189
/**
190+
* Retrieve save and edit button html
191+
*
171192
* @return string
172193
*/
173194
public function getSaveAndEditButtonHtml()
@@ -176,6 +197,8 @@ public function getSaveAndEditButtonHtml()
176197
}
177198

178199
/**
200+
* Retrieve delete button html
201+
*
179202
* @return string
180203
*/
181204
public function getDeleteButtonHtml()
@@ -194,6 +217,8 @@ public function getSaveSplitButtonHtml()
194217
}
195218

196219
/**
220+
* Retrieve validation url
221+
*
197222
* @return string
198223
*/
199224
public function getValidationUrl()
@@ -202,6 +227,8 @@ public function getValidationUrl()
202227
}
203228

204229
/**
230+
* Retrieve save url
231+
*
205232
* @return string
206233
*/
207234
public function getSaveUrl()
@@ -210,6 +237,8 @@ public function getSaveUrl()
210237
}
211238

212239
/**
240+
* Retrieve save and continue url
241+
*
213242
* @return string
214243
*/
215244
public function getSaveAndContinueUrl()
@@ -221,6 +250,8 @@ public function getSaveAndContinueUrl()
221250
}
222251

223252
/**
253+
* Retrieve product id
254+
*
224255
* @return mixed
225256
*/
226257
public function getProductId()
@@ -229,6 +260,8 @@ public function getProductId()
229260
}
230261

231262
/**
263+
* Retrieve product set id
264+
*
232265
* @return mixed
233266
*/
234267
public function getProductSetId()
@@ -241,6 +274,8 @@ public function getProductSetId()
241274
}
242275

243276
/**
277+
* Retrieve duplicate url
278+
*
244279
* @return string
245280
*/
246281
public function getDuplicateUrl()
@@ -249,6 +284,8 @@ public function getDuplicateUrl()
249284
}
250285

251286
/**
287+
* Retrieve product header
288+
*
252289
* @deprecated 101.1.0
253290
* @return string
254291
*/
@@ -263,6 +300,8 @@ public function getHeader()
263300
}
264301

265302
/**
303+
* Get product attribute set name
304+
*
266305
* @return string
267306
*/
268307
public function getAttributeSetName()
@@ -275,11 +314,14 @@ public function getAttributeSetName()
275314
}
276315

277316
/**
317+
* Retrieve id of selected tab
318+
*
278319
* @return string
279320
*/
280321
public function getSelectedTabId()
281322
{
282-
return addslashes(htmlspecialchars($this->getRequest()->getParam('tab')));
323+
// phpcs:ignore Magento2.Functions.DiscouragedFunction
324+
return addslashes($this->escaper->escapeHtml($this->getRequest()->getParam('tab')));
283325
}
284326

285327
/**

app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductActionGroup.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -485,4 +485,8 @@
485485
<click selector="{{AdminAddUpSellProductsModalSection.AddSelectedProductsButton}}" stepKey="addRelatedProductSelected"/>
486486
<waitForPageLoad stepKey="waitForPageToLoad1"/>
487487
</actionGroup>
488+
<actionGroup name="AdminSetProductDisabled">
489+
<conditionalClick selector="{{AdminProductFormSection.enableProductLabel}}" dependentSelector="{{AdminProductFormSection.productStatusValue('1')}}" visible="true" stepKey="disableProduct"/>
490+
<seeElement selector="{{AdminProductFormSection.productStatusValue('2')}}" stepKey="assertThatProductSetToDisabled"/>
491+
</actionGroup>
488492
</actionGroups>

app/code/Magento/Catalog/Test/Mftf/Section/AdminProductFormSection.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
<element name="enableProductAttributeLabel" type="text" selector="//span[text()='Enable Product']/parent::label"/>
2222
<element name="enableProductAttributeLabelWrapper" type="text" selector="//span[text()='Enable Product']/parent::label/parent::div"/>
2323
<element name="productStatus" type="checkbox" selector="input[name='product[status]']"/>
24+
<element name="productStatusValue" type="checkbox" selector="input[name='product[status]'][value='{{value}}']" timeout="30" parameterized="true"/>
2425
<element name="productStatusDisabled" type="checkbox" selector="input[name='product[status]'][disabled]"/>
2526
<element name="enableProductLabel" type="checkbox" selector="input[name='product[status]']+label"/>
2627
<element name="productStatusUseDefault" type="checkbox" selector="input[name='use_default[status]']"/>

app/code/Magento/Catalog/view/frontend/templates/product/view/details.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
data-toggle="trigger"
2727
href="#<?= $block->escapeUrl($alias) ?>"
2828
id="tab-label-<?= $block->escapeHtmlAttr($alias) ?>-title">
29-
<?= $block->escapeHtml($label) ?>
29+
<?= /* @noEscape */ $label ?>
3030
</a>
3131
</div>
3232
<div class="data item content"

app/code/Magento/CatalogInventory/Model/Quote/Item/QuantityValidator/Initializer/StockItem.php

Lines changed: 35 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,15 @@
77

88
use Magento\Catalog\Model\ProductTypes\ConfigInterface;
99
use Magento\CatalogInventory\Api\StockStateInterface;
10+
use Magento\CatalogInventory\Api\Data\StockItemInterface;
1011
use Magento\CatalogInventory\Model\Quote\Item\QuantityValidator\QuoteItemQtyList;
12+
use Magento\CatalogInventory\Model\Spi\StockStateProviderInterface;
13+
use Magento\Framework\App\ObjectManager;
14+
use Magento\Quote\Model\Quote\Item;
1115

16+
/**
17+
* Class StockItem initializes stock item and populates it with data
18+
*/
1219
class StockItem
1320
{
1421
/**
@@ -26,26 +33,35 @@ class StockItem
2633
*/
2734
protected $stockState;
2835

36+
/**
37+
* @var StockStateProviderInterface
38+
*/
39+
private $stockStateProvider;
40+
2941
/**
3042
* @param ConfigInterface $typeConfig
3143
* @param QuoteItemQtyList $quoteItemQtyList
3244
* @param StockStateInterface $stockState
45+
* @param StockStateProviderInterface|null $stockStateProvider
3346
*/
3447
public function __construct(
3548
ConfigInterface $typeConfig,
3649
QuoteItemQtyList $quoteItemQtyList,
37-
StockStateInterface $stockState
50+
StockStateInterface $stockState,
51+
StockStateProviderInterface $stockStateProvider = null
3852
) {
3953
$this->quoteItemQtyList = $quoteItemQtyList;
4054
$this->typeConfig = $typeConfig;
4155
$this->stockState = $stockState;
56+
$this->stockStateProvider = $stockStateProvider ?: ObjectManager::getInstance()
57+
->get(StockStateProviderInterface::class);
4258
}
4359

4460
/**
4561
* Initialize stock item
4662
*
47-
* @param \Magento\CatalogInventory\Api\Data\StockItemInterface $stockItem
48-
* @param \Magento\Quote\Model\Quote\Item $quoteItem
63+
* @param StockItemInterface $stockItem
64+
* @param Item $quoteItem
4965
* @param int $qty
5066
*
5167
* @return \Magento\Framework\DataObject
@@ -54,11 +70,14 @@ public function __construct(
5470
* @SuppressWarnings(PHPMD.NPathComplexity)
5571
*/
5672
public function initialize(
57-
\Magento\CatalogInventory\Api\Data\StockItemInterface $stockItem,
58-
\Magento\Quote\Model\Quote\Item $quoteItem,
73+
StockItemInterface $stockItem,
74+
Item $quoteItem,
5975
$qty
6076
) {
6177
$product = $quoteItem->getProduct();
78+
$quoteItemId = $quoteItem->getId();
79+
$quoteId = $quoteItem->getQuoteId();
80+
$productId = $product->getId();
6281
/**
6382
* When we work with subitem
6483
*/
@@ -68,14 +87,14 @@ public function initialize(
6887
* we are using 0 because original qty was processed
6988
*/
7089
$qtyForCheck = $this->quoteItemQtyList
71-
->getQty($product->getId(), $quoteItem->getId(), $quoteItem->getQuoteId(), 0);
90+
->getQty($productId, $quoteItemId, $quoteId, 0);
7291
} else {
7392
$increaseQty = $quoteItem->getQtyToAdd() ? $quoteItem->getQtyToAdd() : $qty;
7493
$rowQty = $qty;
7594
$qtyForCheck = $this->quoteItemQtyList->getQty(
76-
$product->getId(),
77-
$quoteItem->getId(),
78-
$quoteItem->getQuoteId(),
95+
$productId,
96+
$quoteItemId,
97+
$quoteId,
7998
$increaseQty
8099
);
81100
}
@@ -90,14 +109,20 @@ public function initialize(
90109

91110
$stockItem->setProductName($product->getName());
92111

112+
/** @var \Magento\Framework\DataObject $result */
93113
$result = $this->stockState->checkQuoteItemQty(
94-
$product->getId(),
114+
$productId,
95115
$rowQty,
96116
$qtyForCheck,
97117
$qty,
98118
$product->getStore()->getWebsiteId()
99119
);
100120

121+
/* We need to ensure that any possible plugin will not erase the data */
122+
$backOrdersQty = $this->stockStateProvider->checkQuoteItemQty($stockItem, $rowQty, $qtyForCheck, $qty)
123+
->getItemBackorders();
124+
$result->setItemBackorders($backOrdersQty);
125+
101126
if ($stockItem->hasIsChildItem()) {
102127
$stockItem->unsIsChildItem();
103128
}

0 commit comments

Comments
 (0)