Skip to content

Commit 3a23292

Browse files
committed
Merge remote-tracking branch 'origin/2.4-develop' into ACP2E-4270
2 parents 667eacf + ab89130 commit 3a23292

File tree

15,974 files changed

+50648
-40235
lines changed

Some content is hidden

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

15,974 files changed

+50648
-40235
lines changed

app/code/Magento/Backend/Block/Cache.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/**
3-
* Copyright 2013 Adobe
3+
* Copyright 2011 Adobe
44
* All Rights Reserved.
55
*/
66
namespace Magento\Backend\Block;
@@ -35,7 +35,11 @@ protected function _construct()
3535
}
3636

3737
if ($this->_authorization->isAllowed('Magento_Backend::flush_cache_storage')) {
38-
$message = __('The cache storage may contain additional data. Are you sure that you want to flush it?');
38+
$message = $this->escapeJs(
39+
$this->escapeHtml(
40+
__('The cache storage may contain additional data. Are you sure that you want to flush it?')
41+
)
42+
);
3943
$this->buttonList->add(
4044
'flush_system',
4145
[

app/code/Magento/Backend/Block/System/Design/Edit.php

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
<?php
22
/**
3-
* Copyright 2013 Adobe
3+
* Copyright 2011 Adobe
44
* All Rights Reserved.
55
*/
66
namespace Magento\Backend\Block\System\Design;
77

8+
use Magento\Framework\Escaper;
9+
use Magento\Framework\App\ObjectManager;
10+
811
/**
912
* Edit store design schedule block.
1013
*/
@@ -16,25 +19,35 @@ class Edit extends \Magento\Backend\Block\Widget
1619
protected $_template = 'Magento_Backend::system/design/edit.phtml';
1720

1821
/**
19-
* Core registry
22+
* Application data storage
2023
*
2124
* @var \Magento\Framework\Registry
2225
*/
2326
protected $_coreRegistry = null;
2427

28+
/**
29+
* Escaper for secure output rendering
30+
*
31+
* @var Escaper
32+
*/
33+
private $escaper;
34+
2535
/**
2636
* @inheritdoc
2737
*
2838
* @param \Magento\Backend\Block\Template\Context $context
2939
* @param \Magento\Framework\Registry $registry
3040
* @param array $data
41+
* @param Escaper|null $escaper
3142
*/
3243
public function __construct(
3344
\Magento\Backend\Block\Template\Context $context,
3445
\Magento\Framework\Registry $registry,
35-
array $data = []
46+
array $data = [],
47+
?Escaper $escaper = null
3648
) {
3749
$this->_coreRegistry = $registry;
50+
$this->escaper = $escaper ?? ObjectManager::getInstance()->get(Escaper::class);
3851
parent::__construct($context, $data);
3952
}
4053

@@ -66,14 +79,17 @@ protected function _prepareLayout()
6679
);
6780

6881
if ($this->getDesignChangeId()) {
82+
$confirmMessage = $this->escaper->escapeJs(
83+
$this->escaper->escapeHtml(__('Are you sure?'))
84+
);
85+
$deleteOnClick = 'deleteConfirm(\'' . $confirmMessage . '\', \'' .
86+
$this->getDeleteUrl() . '\', {data: {}})';
6987
$this->getToolbar()->addChild(
7088
'delete_button',
7189
\Magento\Backend\Block\Widget\Button::class,
7290
[
7391
'label' => __('Delete'),
74-
'onclick' => 'deleteConfirm(\'' . __(
75-
'Are you sure?'
76-
) . '\', \'' . $this->getDeleteUrl() . '\', {data: {}})',
92+
'onclick' => $deleteOnClick,
7793
'class' => 'delete'
7894
]
7995
);

app/code/Magento/Backend/Block/Widget/Form/Container.php

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/**
3-
* Copyright 2013 Adobe
3+
* Copyright 2011 Adobe
44
* All Rights Reserved.
55
*/
66
namespace Magento\Backend\Block\Widget\Form;
@@ -13,7 +13,8 @@
1313
* Backend form container block
1414
*
1515
* @api
16-
* @deprecated 100.2.0 in favour of UI component implementation
16+
* @deprecated 100.2.0 Use UI components for form rendering instead of this legacy form container
17+
* @see \Magento\Ui\Component\Form
1718
* @SuppressWarnings(PHPMD.NumberOfChildren)
1819
* @since 100.0.2
1920
*/
@@ -45,14 +46,14 @@ class Container extends \Magento\Backend\Block\Widget\Container
4546
protected $_blockGroup = 'Magento_Backend';
4647

4748
/**
48-
* @var string
49+
* @var string
4950
*/
50-
const PARAM_BLOCK_GROUP = 'block_group';
51+
public const PARAM_BLOCK_GROUP = 'block_group';
5152

5253
/**
53-
* @var string
54+
* @var string
5455
*/
55-
const PARAM_MODE = 'mode';
56+
public const PARAM_MODE = 'mode';
5657

5758
/**
5859
* @var string
@@ -111,14 +112,17 @@ protected function _construct()
111112
$objId = (int)$this->getRequest()->getParam($this->_objectId);
112113

113114
if (!empty($objId)) {
115+
$confirmMessage = $this->escapeJs(
116+
$this->escapeHtml(__('Are you sure you want to do this?'))
117+
);
118+
$deleteOnClick = 'deleteConfirm(\'' . $confirmMessage . '\', \'' .
119+
$this->getDeleteUrl() . '\', {data: {}})';
114120
$this->addButton(
115121
'delete',
116122
[
117123
'label' => __('Delete'),
118124
'class' => 'delete',
119-
'onclick' => 'deleteConfirm(\'' . __(
120-
'Are you sure you want to do this?'
121-
) . '\', \'' . $this->getDeleteUrl() . '\', {data: {}})'
125+
'onclick' => $deleteOnClick
122126
]
123127
);
124128
}

app/code/Magento/Bundle/Model/LinkManagement.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,9 @@ private function processLinkedProduct(
252252
throw new CouldNotSaveException(__('Could not save child: "%1"', $e->getMessage()), $e);
253253
}
254254

255+
$linkedProduct->setId($selectionModel->getId());
256+
$linkedProduct->setSelectionId($selectionModel->getId());
257+
$linkedProduct->setOptionId($optionId);
255258
return (int)$selectionModel->getId();
256259
}
257260

@@ -450,14 +453,16 @@ public function removeChild($sku, $optionId, $childSku)
450453
$excludeSelectionIds = [];
451454
$usedProductIds = [];
452455
$removeSelectionIds = [];
456+
$removeProductIds = [];
453457
foreach ($this->getOptions($product) as $option) {
454458
/** @var Selection $selection */
455459
foreach ($option->getSelections() as $selection) {
456460
if ((strcasecmp($selection->getSku(), $childSku) == 0) && ($selection->getOptionId() == $optionId)) {
457461
$removeSelectionIds[] = $selection->getSelectionId();
458-
$usedProductIds[] = $selection->getProductId();
462+
$removeProductIds[] = $selection->getProductId();
459463
continue;
460464
}
465+
$usedProductIds[] = $selection->getProductId();
461466
$excludeSelectionIds[] = $selection->getSelectionId();
462467
}
463468
}
@@ -470,7 +475,10 @@ public function removeChild($sku, $optionId, $childSku)
470475
/* @var $resource Bundle */
471476
$resource = $this->bundleFactory->create();
472477
$resource->dropAllUnneededSelections($product->getData($linkField), $excludeSelectionIds);
473-
$resource->removeProductRelations($product->getData($linkField), array_unique($usedProductIds));
478+
$productRelationsToRemove = array_diff($removeProductIds, $usedProductIds);
479+
if ($productRelationsToRemove) {
480+
$resource->removeProductRelations($product->getData($linkField), array_unique($productRelationsToRemove));
481+
}
474482

475483
return true;
476484
}

app/code/Magento/Bundle/Model/Product/CopyConstructor/Bundle.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,15 @@ public function build(Product $product, Product $duplicate)
3535
* Set option and selection ids to 'null' in order to create new option(selection) for duplicated product,
3636
* but not modifying existing one, which led to lost of option(selection) in original product.
3737
*/
38-
$productLinks = $duplicatedBundleOption->getProductLinks() ?: [];
39-
foreach ($productLinks as $productLink) {
40-
$productLink->setSelectionId(null);
38+
$productLinks = [];
39+
foreach ($duplicatedBundleOption->getProductLinks() ?: [] as $productLink) {
40+
$productLinkDuplicate = clone $productLink;
41+
$productLinkDuplicate->setId(null);
42+
$productLinkDuplicate->setSelectionId(null);
43+
$productLinkDuplicate->setOptionId(null);
44+
$productLinks[] = $productLinkDuplicate;
4145
}
46+
$duplicatedBundleOption->setProductLinks($productLinks);
4247
$duplicatedBundleOption->setOptionId(null);
4348
$duplicatedBundleOptions[$key] = $duplicatedBundleOption;
4449
}

app/code/Magento/Bundle/Model/Product/SaveHandler.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,10 +141,7 @@ protected function removeOptionLinks($entitySku, $option)
141141
$links = $option->getProductLinks();
142142
if (!empty($links)) {
143143
foreach ($links as $link) {
144-
$linkCanBeDeleted = $this->checkOptionLinkIfExist->execute($entitySku, $option, $link);
145-
if ($linkCanBeDeleted) {
146-
$this->productLinkManagement->removeChild($entitySku, $option->getId(), $link->getSku());
147-
}
144+
$this->productLinkManagement->removeChild($entitySku, $option->getId(), $link->getSku());
148145
}
149146
}
150147
}

app/code/Magento/Bundle/Test/Unit/Model/LinkManagementTest.php

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -639,14 +639,11 @@ static function () {
639639
*/
640640
public function testAddChild(): void
641641
{
642-
$productLink = $this->getMockBuilder(LinkInterface::class)
643-
->onlyMethods(['getSku', 'getOptionId'])
644-
->addMethods(['getSelectionId'])
645-
->disableOriginalConstructor()
646-
->getMockForAbstractClass();
647-
$productLink->method('getSku')->willReturn('linked_product_sku');
648-
$productLink->method('getOptionId')->willReturn(1);
649-
$productLink->method('getSelectionId')->willReturn(1);
642+
$selectionId = 42;
643+
$optionId = 1;
644+
$sku = 'linked_product_sku';
645+
$productLink = $this->createPartialMock(\Magento\Bundle\Model\Link::class, []);
646+
$productLink->setSku($sku);
650647

651648
$this->metadataMock->expects($this->exactly(2))->method('getLinkField')->willReturn($this->linkField);
652649
$productMock = $this->createMock(Product::class);
@@ -662,7 +659,7 @@ public function testAddChild(): void
662659
$this->productRepository
663660
->expects($this->once())
664661
->method('get')
665-
->with('linked_product_sku')
662+
->with($sku)
666663
->willReturn($linkedProductMock);
667664

668665
$store = $this->createMock(Store::class);
@@ -698,10 +695,14 @@ public function testAddChild(): void
698695

699696
$selection = $this->createPartialMock(Selection::class, ['save', 'getId', 'load']);
700697
$selection->expects($this->once())->method('save');
701-
$selection->expects($this->once())->method('getId')->willReturn(42);
698+
$selection->expects($this->any())->method('getId')->willReturn($selectionId);
702699
$this->bundleSelectionMock->expects($this->once())->method('create')->willReturn($selection);
703-
$result = $this->model->addChild($productMock, 1, $productLink);
704-
$this->assertEquals(42, $result);
700+
701+
$result = $this->model->addChild($productMock, $optionId, $productLink);
702+
$this->assertEquals($selectionId, $result);
703+
$this->assertEquals($selectionId, $productLink->getId());
704+
$this->assertEquals($selectionId, $productLink->getSelectionId());
705+
$this->assertEquals($optionId, $productLink->getOptionId());
705706
}
706707

707708
/**

0 commit comments

Comments
 (0)