Skip to content

Commit 3a1acc6

Browse files
merge magento/2.3.3-develop into magento-arcticfoxes/MC-17648
2 parents 8334ad0 + e947753 commit 3a1acc6

File tree

37 files changed

+787
-113
lines changed

37 files changed

+787
-113
lines changed

app/code/Magento/Catalog/Model/Product/Compare/ListCompare.php

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@
55
*/
66
namespace Magento\Catalog\Model\Product\Compare;
77

8+
use Magento\Catalog\Model\ProductRepository;
89
use Magento\Catalog\Model\ResourceModel\Product\Compare\Item\Collection;
10+
use Magento\Framework\App\ObjectManager;
11+
use Magento\Framework\Exception\NoSuchEntityException;
912

1013
/**
1114
* Product Compare List Model
@@ -51,6 +54,11 @@ class ListCompare extends \Magento\Framework\DataObject
5154
*/
5255
protected $_compareItemFactory;
5356

57+
/**
58+
* @var ProductRepository
59+
*/
60+
private $productRepository;
61+
5462
/**
5563
* Constructor
5664
*
@@ -60,20 +68,23 @@ class ListCompare extends \Magento\Framework\DataObject
6068
* @param \Magento\Customer\Model\Session $customerSession
6169
* @param \Magento\Customer\Model\Visitor $customerVisitor
6270
* @param array $data
71+
* @param ProductRepository|null $productRepository
6372
*/
6473
public function __construct(
6574
\Magento\Catalog\Model\Product\Compare\ItemFactory $compareItemFactory,
6675
\Magento\Catalog\Model\ResourceModel\Product\Compare\Item\CollectionFactory $itemCollectionFactory,
6776
\Magento\Catalog\Model\ResourceModel\Product\Compare\Item $catalogProductCompareItem,
6877
\Magento\Customer\Model\Session $customerSession,
6978
\Magento\Customer\Model\Visitor $customerVisitor,
70-
array $data = []
79+
array $data = [],
80+
ProductRepository $productRepository = null
7181
) {
7282
$this->_compareItemFactory = $compareItemFactory;
7383
$this->_itemCollectionFactory = $itemCollectionFactory;
7484
$this->_catalogProductCompareItem = $catalogProductCompareItem;
7585
$this->_customerSession = $customerSession;
7686
$this->_customerVisitor = $customerVisitor;
87+
$this->productRepository = $productRepository ?: ObjectManager::getInstance()->create(ProductRepository::class);
7788
parent::__construct($data);
7889
}
7990

@@ -82,6 +93,7 @@ public function __construct(
8293
*
8394
* @param int|\Magento\Catalog\Model\Product $product
8495
* @return $this
96+
* @throws \Exception
8597
*/
8698
public function addProduct($product)
8799
{
@@ -90,14 +102,33 @@ public function addProduct($product)
90102
$this->_addVisitorToItem($item);
91103
$item->loadByProduct($product);
92104

93-
if (!$item->getId()) {
105+
if (!$item->getId() && $this->productExists($product)) {
94106
$item->addProductData($product);
95107
$item->save();
96108
}
97109

98110
return $this;
99111
}
100112

113+
/**
114+
* Check product exists.
115+
*
116+
* @param int|\Magento\Catalog\Model\Product $product
117+
* @return bool
118+
*/
119+
private function productExists($product)
120+
{
121+
if ($product instanceof \Magento\Catalog\Model\Product && $product->getId()) {
122+
return true;
123+
}
124+
try {
125+
$product = $this->productRepository->getById((int)$product);
126+
return !empty($product->getId());
127+
} catch (NoSuchEntityException $e) {
128+
return false;
129+
}
130+
}
131+
101132
/**
102133
* Add products to compare list
103134
*

app/code/Magento/Checkout/Test/Mftf/Test/StorefrontUKCustomerCheckoutWithCouponTest.xml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
</annotations>
1919

2020
<before>
21-
<actionGroup ref="LoginAsAdmin" stepKey="loginToAdminPanel"/>
21+
<magentoCLI command="downloadable:domains:add" arguments="example.com static.magento.com" stepKey="addDownloadableDomain"/>
2222
<createData entity="ApiDownloadableProduct" stepKey="createDownloadableProduct">
2323
<field key="price">20.00</field>
2424
</createData>
@@ -38,10 +38,12 @@
3838
</createData>
3939
</before>
4040
<after>
41+
<magentoCLI command="downloadable:domains:remove" arguments="example.com static.magento.com" stepKey="removeDownloadableDomain"/>
4142
<deleteData createDataKey="createDownloadableProduct" stepKey="deleteProduct"/>
4243
<deleteData createDataKey="virtualProduct" stepKey="deleteVirtualProduct"/>
4344
<deleteData createDataKey="createCustomer" stepKey="deleteCustomer"/>
4445
<deleteData createDataKey="createSalesRule" stepKey="deleteSalesRule"/>
46+
<actionGroup ref="AdminOrdersGridClearFiltersActionGroup" stepKey="clearOrderFilters"/>
4547
<actionGroup ref="logout" stepKey="logout"/>
4648
</after>
4749

@@ -106,6 +108,9 @@
106108
<seeElement selector="{{StorefrontMiniCartSection.emptyMiniCart}}" stepKey="assertEmptyCart" />
107109
<grabTextFrom selector="{{CheckoutSuccessMainSection.orderLink}}" stepKey="orderId"/>
108110

111+
<!-- Login to Admin Page -->
112+
<actionGroup ref="LoginAsAdmin" stepKey="loginToAdminPanel"/>
113+
109114
<!-- Open Order Index Page -->
110115
<amOnPage url="{{AdminOrdersPage.url}}" stepKey="goToOrders"/>
111116
<waitForPageLoad stepKey="waitForPageLoad5"/>
@@ -127,4 +132,4 @@
127132
<see selector="{{AdminOrderTotalSection.grandTotal}}" userInput="$15.00" stepKey="seeGrandTotal"/>
128133
<see selector="{{AdminOrderDetailsInformationSection.orderStatus}}" userInput="Pending" stepKey="seeOrderStatus"/>
129134
</test>
130-
</tests>
135+
</tests>

app/code/Magento/Customer/Test/Mftf/Section/AdminCustomerAddressesGridActionsSection.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,6 @@
1717
<element name="filters" type="button" selector="button[data-action='grid-filter-expand']" timeout="30"/>
1818
<element name="ok" type="button" selector="//button[@data-role='action']//span[text()='OK']" timeout="30"/>
1919
<element name="headerRow" type="text" selector=".admin__data-grid-header-row.row.row-gutter"/>
20+
<element name="clearFilter" type="button" selector=".admin__data-grid-header .admin__data-grid-filters-current button.action-clear" timeout="30"/>
2021
</section>
2122
</sections>

app/code/Magento/Customer/Test/Mftf/Test/AdminCreateCustomerWithCountryUSATest.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@
8585
<see selector="{{AdminCustomerAddressesDefaultBillingSection.addressDetails}}" userInput="{{US_Address_CA.telephone}}" stepKey="seePhoneNumberInDefaultAddressSection"/>
8686

8787
<!--Assert Customer Address Grid -->
88+
<conditionalClick selector="{{AdminCustomerAddressesGridActionsSection.clearFilter}}" dependentSelector="{{AdminCustomerAddressesGridActionsSection.clearFilter}}" visible="true" stepKey="clearAddressesGridFilter"/>
8889
<see selector="{{AdminCustomerAddressesGridSection.customerAddressGrid}}" userInput="{{US_Address_CA.street}}" stepKey="seeStreetAddress"/>
8990
<see selector="{{AdminCustomerAddressesGridSection.customerAddressGrid}}" userInput="{{US_Address_CA.city}}" stepKey="seeCity"/>
9091
<see selector="{{AdminCustomerAddressesGridSection.customerAddressGrid}}" userInput="{{US_Address_CA.country}}" stepKey="seeCountry"/>

app/code/Magento/Downloadable/Controller/Adminhtml/Downloadable/File/Upload.php

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
use Magento\Framework\App\Action\HttpPostActionInterface;
99
use Magento\Framework\Controller\ResultFactory;
10+
use Magento\Framework\Exception\FileSystemException;
11+
use Magento\Framework\Exception\LocalizedException;
1012

1113
/**
1214
* Class Upload
@@ -76,23 +78,27 @@ public function __construct(
7678
*/
7779
public function execute()
7880
{
79-
$type = $this->getRequest()->getParam('type');
80-
$tmpPath = '';
81-
if ($type == 'samples') {
82-
$tmpPath = $this->_sample->getBaseTmpPath();
83-
} elseif ($type == 'links') {
84-
$tmpPath = $this->_link->getBaseTmpPath();
85-
} elseif ($type == 'link_samples') {
86-
$tmpPath = $this->_link->getBaseSampleTmpPath();
87-
}
88-
8981
try {
82+
$type = $this->getRequest()->getParam('type');
83+
$tmpPath = '';
84+
if ($type === 'samples') {
85+
$tmpPath = $this->_sample->getBaseTmpPath();
86+
} elseif ($type === 'links') {
87+
$tmpPath = $this->_link->getBaseTmpPath();
88+
} elseif ($type === 'link_samples') {
89+
$tmpPath = $this->_link->getBaseSampleTmpPath();
90+
} else {
91+
throw new LocalizedException(__('Upload type can not be determined.'));
92+
}
93+
9094
$uploader = $this->uploaderFactory->create(['fileId' => $type]);
9195

9296
$result = $this->_fileHelper->uploadFromTmp($tmpPath, $uploader);
9397

9498
if (!$result) {
95-
throw new \Exception('File can not be moved from temporary folder to the destination folder.');
99+
throw new FileSystemException(
100+
__('File can not be moved from temporary folder to the destination folder.')
101+
);
96102
}
97103

98104
unset($result['tmp_name'], $result['path']);
@@ -101,7 +107,7 @@ public function execute()
101107
$relativePath = rtrim($tmpPath, '/') . '/' . ltrim($result['file'], '/');
102108
$this->storageDatabase->saveFile($relativePath);
103109
}
104-
} catch (\Exception $e) {
110+
} catch (\Throwable $e) {
105111
$result = ['error' => $e->getMessage(), 'errorcode' => $e->getCode()];
106112
}
107113

app/code/Magento/Downloadable/Setup/Patch/Data/AddDownloadableHostsConfig.php

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,13 @@
77

88
namespace Magento\Downloadable\Setup\Patch\Data;
99

10+
use Magento\Config\Model\Config\Backend\Admin\Custom;
1011
use Magento\Framework\App\Config\ScopeConfigInterface;
12+
use Magento\Framework\Exception\NoSuchEntityException;
1113
use Magento\Framework\Setup\Patch\DataPatchInterface;
14+
use Magento\Framework\UrlInterface;
1215
use Magento\Store\Model\ScopeInterface;
16+
use Magento\Store\Model\Store;
1317
use Zend\Uri\Uri as UriHandler;
1418
use Magento\Framework\Url\ScopeResolverInterface;
1519
use Magento\Downloadable\Api\DomainManagerInterface as DomainManager;
@@ -79,8 +83,12 @@ public function __construct(
7983
*/
8084
public function apply()
8185
{
82-
foreach ($this->scopeResolver->getScopes() as $scope) {
83-
$this->addHost($scope->getBaseUrl());
86+
$customStoreScope = $this->scopeResolver->getScope(Custom::CONFIG_SCOPE_ID);
87+
$storeScopes = $this->scopeResolver->getScopes();
88+
$allStoreScopes = array_merge($storeScopes, [$customStoreScope]);
89+
90+
foreach ($allStoreScopes as $scope) {
91+
$this->addStoreAndWebsiteUrlsFromScope($scope);
8492
}
8593

8694
$customAdminUrl = $this->scopeConfig->getValue(
@@ -135,13 +143,56 @@ public function apply()
135143
$this->domainManager->addDomains($this->whitelist);
136144
}
137145

146+
/**
147+
* Add stores and website urls from store scope
148+
*
149+
* @param Store $scope
150+
*/
151+
private function addStoreAndWebsiteUrlsFromScope(Store $scope)
152+
{
153+
$this->addHost($scope->getBaseUrl(UrlInterface::URL_TYPE_WEB, false));
154+
$this->addHost($scope->getBaseUrl(UrlInterface::URL_TYPE_WEB, true));
155+
$this->addHost($scope->getBaseUrl(UrlInterface::URL_TYPE_LINK, false));
156+
$this->addHost($scope->getBaseUrl(UrlInterface::URL_TYPE_LINK, true));
157+
$this->addHost($scope->getBaseUrl(UrlInterface::URL_TYPE_DIRECT_LINK, false));
158+
$this->addHost($scope->getBaseUrl(UrlInterface::URL_TYPE_DIRECT_LINK, true));
159+
$this->addHost($scope->getBaseUrl(UrlInterface::URL_TYPE_MEDIA, false));
160+
$this->addHost($scope->getBaseUrl(UrlInterface::URL_TYPE_MEDIA, true));
161+
162+
try {
163+
$this->addHost($scope->getBaseUrl(UrlInterface::URL_TYPE_STATIC, false));
164+
$this->addHost($scope->getBaseUrl(UrlInterface::URL_TYPE_STATIC, true));
165+
} catch (\UnexpectedValueException $e) {} //@codingStandardsIgnoreLine
166+
167+
try {
168+
$website = $scope->getWebsite();
169+
} catch (NoSuchEntityException $e) {
170+
return;
171+
}
172+
173+
if ($website) {
174+
$this->addHost($website->getConfig(Store::XML_PATH_SECURE_BASE_URL));
175+
$this->addHost($website->getConfig(Store::XML_PATH_UNSECURE_BASE_URL));
176+
$this->addHost($website->getConfig(Store::XML_PATH_SECURE_BASE_LINK_URL));
177+
$this->addHost($website->getConfig(Store::XML_PATH_UNSECURE_BASE_LINK_URL));
178+
$this->addHost($website->getConfig(Store::XML_PATH_SECURE_BASE_MEDIA_URL));
179+
$this->addHost($website->getConfig(Store::XML_PATH_UNSECURE_BASE_MEDIA_URL));
180+
$this->addHost($website->getConfig(Store::XML_PATH_SECURE_BASE_STATIC_URL));
181+
$this->addHost($website->getConfig(Store::XML_PATH_UNSECURE_BASE_STATIC_URL));
182+
}
183+
}
184+
138185
/**
139186
* Add host to whitelist
140187
*
141188
* @param string $url
142189
*/
143190
private function addHost($url)
144191
{
192+
if (!is_string($url)) {
193+
return;
194+
}
195+
145196
$host = $this->uriHandler->parse($url)->getHost();
146197
if ($host && !in_array($host, $this->whitelist)) {
147198
$this->whitelist[] = $host;

app/code/Magento/Eav/Model/ResourceModel/Entity/Attribute.php

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
use Magento\Eav\Model\Entity\Attribute as EntityAttribute;
1212
use Magento\Framework\App\ObjectManager;
1313
use Magento\Framework\DB\Select;
14+
use Magento\Framework\Exception\CouldNotDeleteException;
1415
use Magento\Framework\Model\AbstractModel;
16+
use Magento\Framework\Model\ResourceModel\Db\AbstractDb;
1517

1618
/**
1719
* EAV attribute resource model
@@ -20,7 +22,7 @@
2022
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
2123
* @since 100.0.2
2224
*/
23-
class Attribute extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb
25+
class Attribute extends AbstractDb
2426
{
2527
/**
2628
* Eav Entity attributes cache
@@ -189,6 +191,23 @@ protected function _beforeSave(AbstractModel $object)
189191
return parent::_beforeSave($object);
190192
}
191193

194+
/**
195+
* @inheritdoc
196+
*
197+
* @param AbstractModel $attribute
198+
* @return AbstractDb
199+
* @throws CouldNotDeleteException
200+
*/
201+
protected function _beforeDelete(AbstractModel $attribute)
202+
{
203+
/** @var $attribute \Magento\Eav\Api\Data\AttributeInterface */
204+
if ($attribute->getId() && !$attribute->getIsUserDefined()) {
205+
throw new CouldNotDeleteException(__("The system attribute can't be deleted."));
206+
}
207+
208+
return parent::_beforeDelete($attribute);
209+
}
210+
192211
/**
193212
* Save additional attribute data after save attribute
194213
*

app/code/Magento/Email/Block/Adminhtml/Template/Preview.php

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,8 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
declare(strict_types=1);
67

7-
/**
8-
* Adminhtml system template preview block
9-
*
10-
* @author Magento Core Team <core@magentocommerce.com>
11-
*/
128
namespace Magento\Email\Block\Adminhtml\Template;
139

1410
/**
@@ -55,16 +51,12 @@ public function __construct(
5551
* Prepare html output
5652
*
5753
* @return string
58-
* @throws \Magento\Framework\Exception\LocalizedException
54+
* @throws \Exception
5955
*/
6056
protected function _toHtml()
6157
{
6258
$request = $this->getRequest();
6359

64-
if (!$request instanceof \Magento\Framework\App\RequestSafetyInterface || !$request->isSafeMethod()) {
65-
throw new \Magento\Framework\Exception\LocalizedException(__('Wrong request.'));
66-
}
67-
6860
$storeId = $this->getAnyStoreView()->getId();
6961
/** @var $template \Magento\Email\Model\Template */
7062
$template = $this->_emailFactory->create();

app/code/Magento/Email/Controller/Adminhtml/Email/Template/Popup.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77

88
namespace Magento\Email\Controller\Adminhtml\Email\Template;
99

10-
use Magento\Framework\App\Action\HttpGetActionInterface;
10+
use Magento\Framework\App\Action\HttpPostActionInterface;
1111

1212
/**
1313
* Rendering popup email template.
1414
*/
15-
class Popup extends \Magento\Backend\App\Action implements HttpGetActionInterface
15+
class Popup extends \Magento\Backend\App\Action implements HttpPostActionInterface
1616
{
1717
/**
1818
* @var \Magento\Framework\View\Result\PageFactory

0 commit comments

Comments
 (0)