Skip to content

Commit d0e2b77

Browse files
merge magento/2.3-develop into magento-engcom/fix-nightly-fails-with-msi
2 parents 7a94754 + 1ebd7cc commit d0e2b77

File tree

181 files changed

+9893
-1157
lines changed

Some content is hidden

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

181 files changed

+9893
-1157
lines changed

app/code/Magento/AdminAnalytics/view/adminhtml/ui_component/admin_usage_notification.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585
<item name="text" xsi:type="string" translate="true"><![CDATA[
8686
<p>Help us improve Magento Admin by allowing us to collect usage data.</p>
8787
<p>All usage data that we collect for this purpose cannot be used to individually identify you and is used only to improve the Magento Admin and related products and services.</p>
88-
<p>You can learn more and opt out at any time by following the instructions in <a href="https://docs.magento.com/m2/ce/user_guide/stores/admin.html" target="_blank">merchant documentation</a>.</p>
88+
<p>You can learn more and opt out at any time by following the instructions in <a href="https://docs.magento.com/m2/ce/user_guide/stores/admin.html" target="_blank" tabindex="0">merchant documentation</a>.</p>
8989
]]></item>
9090
</item>
9191
</argument>

app/code/Magento/AdminAnalytics/view/adminhtml/web/js/modal/component.js

+84-13
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,7 @@ define([
2020
enableLogAction: '${ $.provider }:data.enableLogAction',
2121
disableLogAction: '${ $.provider }:data.disableLogAction'
2222
},
23-
options: {
24-
keyEventHandlers: {
25-
/**
26-
* Prevents escape key from exiting out of modal
27-
*/
28-
escapeKey: function () {
29-
return;
30-
}
31-
}
32-
},
23+
options: {},
3324
notificationWindow: null
3425
},
3526

@@ -41,11 +32,32 @@ define([
4132
this._super();
4233
},
4334

35+
/**
36+
* Configure ESC and TAB so user can't leave modal
37+
* without selecting an option
38+
*
39+
* @returns {Object} Chainable.
40+
*/
41+
initModalEvents: function () {
42+
this._super();
43+
//Don't allow ESC key to close modal
44+
this.options.keyEventHandlers.escapeKey = this.handleEscKey.bind(this);
45+
//Restrict tab action to the modal
46+
this.options.keyEventHandlers.tabKey = this.handleTabKey.bind(this);
47+
48+
return this;
49+
},
50+
4451
/**
4552
* Once the modal is opened it hides the X
4653
*/
4754
onOpened: function () {
48-
$('.modal-header button.action-close').hide();
55+
$('.modal-header button.action-close').attr('disabled', true).hide();
56+
57+
this.focusableElements = $(this.rootSelector).find('a[href], button:enabled');
58+
this.firstFocusableElement = this.focusableElements[0];
59+
this.lastFocusableElement = this.focusableElements[this.focusableElements.length - 1];
60+
this.firstFocusableElement.focus();
4961
},
5062

5163
/**
@@ -104,11 +116,70 @@ define([
104116
* Allows admin usage popup to be shown first and then new release notification
105117
*/
106118
openReleasePopup: function () {
107-
var notifiModal = registry.get('release_notification.release_notification.notification_modal_1');
119+
var notificationModalSelector = 'release_notification.release_notification.notification_modal_1';
108120

109121
if (analyticsPopupConfig.releaseVisible) {
110-
notifiModal.initializeContentAfterAnalytics();
122+
registry.get(notificationModalSelector).initializeContentAfterAnalytics();
111123
}
124+
},
125+
126+
/**
127+
* Handle Tab and Shift+Tab key event
128+
*
129+
* Keep the tab actions restricted to the popup modal
130+
* so the user must select an option to dismiss the modal
131+
*/
132+
handleTabKey: function (event) {
133+
var modal = this,
134+
KEY_TAB = 9;
135+
136+
/**
137+
* Handle Shift+Tab to tab backwards
138+
*/
139+
function handleBackwardTab() {
140+
if (document.activeElement === modal.firstFocusableElement ||
141+
document.activeElement === $(modal.rootSelector)[0]
142+
) {
143+
event.preventDefault();
144+
modal.lastFocusableElement.focus();
145+
}
146+
}
147+
148+
/**
149+
* Handle Tab forward
150+
*/
151+
function handleForwardTab() {
152+
if (document.activeElement === modal.lastFocusableElement) {
153+
event.preventDefault();
154+
modal.firstFocusableElement.focus();
155+
}
156+
}
157+
158+
switch (event.keyCode) {
159+
case KEY_TAB:
160+
if (modal.focusableElements.length === 1) {
161+
event.preventDefault();
162+
break;
163+
}
164+
165+
if (event.shiftKey) {
166+
handleBackwardTab();
167+
break;
168+
}
169+
handleForwardTab();
170+
break;
171+
default:
172+
break;
173+
}
174+
},
175+
176+
/**
177+
* Handle Esc key
178+
*
179+
* Esc key should not close modal
180+
*/
181+
handleEscKey: function (event) {
182+
event.preventDefault();
112183
}
113184
}
114185
);

app/code/Magento/Catalog/Controller/Adminhtml/Category.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public function __construct(
8282
}
8383

8484
/**
85-
* Initialize requested category and put it into registry
85+
* Initialize requested category and put it into registry.
8686
*
8787
* Root category can be returned, if inappropriate store/category is specified
8888
*
@@ -111,6 +111,8 @@ protected function _initCategory($getRootInstead = false)
111111
}
112112
}
113113

114+
$this->registry->unregister('category');
115+
$this->registry->unregister('current_category');
114116
$this->registry->register('category', $category);
115117
$this->registry->register('current_category', $category);
116118
$this->wysiwigConfig->setStoreId($storeId);

app/code/Magento/Catalog/Controller/Adminhtml/Category/Save.php

+24-18
Original file line numberDiff line numberDiff line change
@@ -183,29 +183,29 @@ public function execute()
183183
$products = json_decode($categoryPostData['category_products'], true);
184184
$category->setPostedProducts($products);
185185
}
186-
$this->_eventManager->dispatch(
187-
'catalog_category_prepare_save',
188-
['category' => $category, 'request' => $this->getRequest()]
189-
);
190186

191-
/**
192-
* Check "Use Default Value" checkboxes values
193-
*/
194-
if (isset($categoryPostData['use_default']) && !empty($categoryPostData['use_default'])) {
195-
foreach ($categoryPostData['use_default'] as $attributeCode => $attributeValue) {
196-
if ($attributeValue) {
197-
$category->setData($attributeCode, null);
187+
try {
188+
$this->_eventManager->dispatch(
189+
'catalog_category_prepare_save',
190+
['category' => $category, 'request' => $this->getRequest()]
191+
);
192+
/**
193+
* Check "Use Default Value" checkboxes values
194+
*/
195+
if (isset($categoryPostData['use_default']) && !empty($categoryPostData['use_default'])) {
196+
foreach ($categoryPostData['use_default'] as $attributeCode => $attributeValue) {
197+
if ($attributeValue) {
198+
$category->setData($attributeCode, null);
199+
}
198200
}
199201
}
200-
}
201202

202-
/**
203-
* Proceed with $_POST['use_config']
204-
* set into category model for processing through validation
205-
*/
206-
$category->setData('use_post_data_config', $useConfig);
203+
/**
204+
* Proceed with $_POST['use_config']
205+
* set into category model for processing through validation
206+
*/
207+
$category->setData('use_post_data_config', $useConfig);
207208

208-
try {
209209
$categoryResource = $category->getResource();
210210
if ($category->hasCustomDesignTo()) {
211211
$categoryResource->getAttribute('custom_design_from')->setMaxValue($category->getCustomDesignTo());
@@ -231,10 +231,16 @@ public function execute()
231231

232232
$category->save();
233233
$this->messageManager->addSuccessMessage(__('You saved the category.'));
234+
// phpcs:disable Magento2.Exceptions.ThrowCatch
234235
} catch (\Magento\Framework\Exception\LocalizedException $e) {
235236
$this->messageManager->addExceptionMessage($e);
236237
$this->logger->critical($e);
237238
$this->_getSession()->setCategoryData($categoryPostData);
239+
// phpcs:disable Magento2.Exceptions.ThrowCatch
240+
} catch (\Throwable $e) {
241+
$this->messageManager->addErrorMessage(__('Something went wrong while saving the category.'));
242+
$this->logger->critical($e);
243+
$this->_getSession()->setCategoryData($categoryPostData);
238244
}
239245
}
240246

app/code/Magento/Catalog/Controller/Adminhtml/Product/Builder.php

+3
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,9 @@ public function build(RequestInterface $request): ProductInterface
115115
$store = $this->storeFactory->create();
116116
$store->load($storeId);
117117

118+
$this->registry->unregister('product');
119+
$this->registry->unregister('current_product');
120+
$this->registry->unregister('current_store');
118121
$this->registry->register('product', $product);
119122
$this->registry->register('current_product', $product);
120123
$this->registry->register('current_store', $store);

app/code/Magento/Catalog/Controller/Adminhtml/Product/Initialization/Helper.php

+13-2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
use Magento\Framework\Stdlib\DateTime\Filter\Date;
2525
use Magento\Store\Model\StoreManagerInterface;
2626
use Zend_Filter_Input;
27+
use Magento\Catalog\Model\Product\Authorization as ProductAuthorization;
2728

2829
/**
2930
* Product helper
@@ -103,6 +104,11 @@ class Helper
103104
*/
104105
private $attributeFilter;
105106

107+
/**
108+
* @var ProductAuthorization
109+
*/
110+
private $productAuthorization;
111+
106112
/**
107113
* @var FormatInterface
108114
*/
@@ -123,6 +129,7 @@ class Helper
123129
* @param LinkTypeProvider|null $linkTypeProvider
124130
* @param AttributeFilter|null $attributeFilter
125131
* @param FormatInterface|null $localeFormat
132+
* @param ProductAuthorization|null $productAuthorization
126133
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
127134
*/
128135
public function __construct(
@@ -137,7 +144,8 @@ public function __construct(
137144
ProductRepositoryInterface $productRepository = null,
138145
LinkTypeProvider $linkTypeProvider = null,
139146
AttributeFilter $attributeFilter = null,
140-
FormatInterface $localeFormat = null
147+
FormatInterface $localeFormat = null,
148+
?ProductAuthorization $productAuthorization = null
141149
) {
142150
$this->request = $request;
143151
$this->storeManager = $storeManager;
@@ -153,6 +161,7 @@ public function __construct(
153161
$this->linkTypeProvider = $linkTypeProvider ?: $objectManager->get(LinkTypeProvider::class);
154162
$this->attributeFilter = $attributeFilter ?: $objectManager->get(AttributeFilter::class);
155163
$this->localeFormat = $localeFormat ?: $objectManager->get(FormatInterface::class);
164+
$this->productAuthorization = $productAuthorization ?? $objectManager->get(ProductAuthorization::class);
156165
}
157166

158167
/**
@@ -243,8 +252,10 @@ public function initializeFromData(Product $product, array $productData)
243252
public function initialize(Product $product)
244253
{
245254
$productData = $this->request->getPost('product', []);
255+
$product = $this->initializeFromData($product, $productData);
256+
$this->productAuthorization->authorizeSavingOf($product);
246257

247-
return $this->initializeFromData($product, $productData);
258+
return $product;
248259
}
249260

250261
/**

app/code/Magento/Catalog/Controller/Category/View.php

+17-3
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
use Magento\Framework\View\Result\PageFactory;
3131
use Magento\Store\Model\StoreManagerInterface;
3232
use Psr\Log\LoggerInterface;
33+
use Magento\Catalog\Model\Category\Attribute\LayoutUpdateManager;
3334

3435
/**
3536
* View a category on storefront. Needs to be accessible by POST because of the store switching.
@@ -96,6 +97,11 @@ class View extends Action implements HttpGetActionInterface, HttpPostActionInter
9697
*/
9798
private $toolbarMemorizer;
9899

100+
/**
101+
* @var LayoutUpdateManager
102+
*/
103+
private $customLayoutManager;
104+
99105
/**
100106
* @var CategoryHelper
101107
*/
@@ -119,7 +125,8 @@ class View extends Action implements HttpGetActionInterface, HttpPostActionInter
119125
* @param ForwardFactory $resultForwardFactory
120126
* @param Resolver $layerResolver
121127
* @param CategoryRepositoryInterface $categoryRepository
122-
* @param ToolbarMemorizer $toolbarMemorizer
128+
* @param ToolbarMemorizer|null $toolbarMemorizer
129+
* @param LayoutUpdateManager|null $layoutUpdateManager
123130
* @param CategoryHelper $categoryHelper
124131
* @param LoggerInterface $logger
125132
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
@@ -136,6 +143,7 @@ public function __construct(
136143
Resolver $layerResolver,
137144
CategoryRepositoryInterface $categoryRepository,
138145
ToolbarMemorizer $toolbarMemorizer = null,
146+
?LayoutUpdateManager $layoutUpdateManager = null,
139147
CategoryHelper $categoryHelper = null,
140148
LoggerInterface $logger = null
141149
) {
@@ -149,8 +157,9 @@ public function __construct(
149157
$this->resultForwardFactory = $resultForwardFactory;
150158
$this->layerResolver = $layerResolver;
151159
$this->categoryRepository = $categoryRepository;
152-
$this->toolbarMemorizer = $toolbarMemorizer ?: ObjectManager::getInstance()
153-
->get(ToolbarMemorizer::class);
160+
$this->toolbarMemorizer = $toolbarMemorizer ?: ObjectManager::getInstance()->get(ToolbarMemorizer::class);
161+
$this->customLayoutManager = $layoutUpdateManager
162+
?? ObjectManager::getInstance()->get(LayoutUpdateManager::class);
154163
$this->categoryHelper = $categoryHelper ?: ObjectManager::getInstance()
155164
->get(CategoryHelper::class);
156165
$this->logger = $logger ?: ObjectManager::getInstance()
@@ -279,5 +288,10 @@ private function applyLayoutUpdates(
279288
$page->addPageLayoutHandles(['layout_update' => sha1($layoutUpdate)], null, false);
280289
}
281290
}
291+
292+
//Selected files
293+
if ($settings->getPageLayoutHandles()) {
294+
$page->addPageLayoutHandles($settings->getPageLayoutHandles());
295+
}
282296
}
283297
}

0 commit comments

Comments
 (0)