diff --git a/README.md b/README.md index aa83b880ca38d..ddd9c310432c7 100644 --- a/README.md +++ b/README.md @@ -89,7 +89,7 @@ Magento is thankful for any contribution that can improve our code base, documen

Reporting security issues

-To report security vulnerabilities in Magento software or web sites, please e-mail security@magento.com. Please do not report security issues using GitHub. Be sure to encrypt your e-mail with our encryption key if it includes sensitive information. Learn more about reporting security issues here. +To report security vulnerabilities in Magento software or web sites, please create a Bugcrowd researcher account there to submit and follow-up your issue. Learn more about reporting security issues here. Stay up-to-date on the latest vulnerabilities and patches for Magento by signing up for Security Alert Notifications. diff --git a/app/code/Magento/AdvancedPricingImportExport/Model/Import/AdvancedPricing.php b/app/code/Magento/AdvancedPricingImportExport/Model/Import/AdvancedPricing.php index 667bc8d9b883c..8e6af26c45150 100644 --- a/app/code/Magento/AdvancedPricingImportExport/Model/Import/AdvancedPricing.php +++ b/app/code/Magento/AdvancedPricingImportExport/Model/Import/AdvancedPricing.php @@ -380,7 +380,7 @@ protected function saveAndReplaceAdvancedPrices() ), 'qty' => $rowData[self::COL_TIER_PRICE_QTY], 'value' => $rowData[self::COL_TIER_PRICE], - 'website_id' => $this->getWebsiteId($rowData[self::COL_TIER_PRICE_WEBSITE]) + 'website_id' => $this->getWebSiteId($rowData[self::COL_TIER_PRICE_WEBSITE]) ]; } } diff --git a/app/code/Magento/Authorizenet/Model/Directpost.php b/app/code/Magento/Authorizenet/Model/Directpost.php index 8e1734a1b893c..07e5f40632d7e 100644 --- a/app/code/Magento/Authorizenet/Model/Directpost.php +++ b/app/code/Magento/Authorizenet/Model/Directpost.php @@ -820,11 +820,14 @@ protected function declineOrder(\Magento\Sales\Model\Order $order, $message = '' { try { $response = $this->getResponse(); - if ( - $voidPayment && $response->getXTransId() && strtoupper($response->getXType()) - == self::REQUEST_TYPE_AUTH_ONLY + if ($voidPayment + && $response->getXTransId() + && strtoupper($response->getXType()) == self::REQUEST_TYPE_AUTH_ONLY ) { - $order->getPayment()->setTransactionId(null)->setParentTransactionId($response->getXTransId())->void(); + $order->getPayment() + ->setTransactionId(null) + ->setParentTransactionId($response->getXTransId()) + ->void($response); } $order->registerCancellation($message)->save(); } catch (\Exception $e) { diff --git a/app/code/Magento/Backend/Block/System/Store/Edit/AbstractForm.php b/app/code/Magento/Backend/Block/System/Store/Edit/AbstractForm.php index f19799d2e4939..034887c67d1ee 100644 --- a/app/code/Magento/Backend/Block/System/Store/Edit/AbstractForm.php +++ b/app/code/Magento/Backend/Block/System/Store/Edit/AbstractForm.php @@ -37,7 +37,7 @@ protected function _prepareForm() ['data' => ['id' => 'edit_form', 'action' => $this->getData('action'), 'method' => 'post']] ); - $this->_prepareStoreFieldSet($form); + $this->_prepareStoreFieldset($form); $form->addField( 'store_type', diff --git a/app/code/Magento/Backend/Block/Widget/Form/Element/Dependence.php b/app/code/Magento/Backend/Block/Widget/Form/Element/Dependence.php index ab45d25451850..632b5c0ff6ad2 100644 --- a/app/code/Magento/Backend/Block/Widget/Form/Element/Dependence.php +++ b/app/code/Magento/Backend/Block/Widget/Form/Element/Dependence.php @@ -120,14 +120,18 @@ protected function _toHtml() if (!$this->_depends) { return ''; } - return ''; + + $params = $this->_getDependsJson(); + + if ($this->_configOptions) { + $params .= ', ' . $this->_jsonEncoder->encode($this->_configOptions); + } + + return ""; } /** diff --git a/app/code/Magento/Backend/Block/Widget/Tabs.php b/app/code/Magento/Backend/Block/Widget/Tabs.php index e3479e817464a..a35edc871aa9c 100644 --- a/app/code/Magento/Backend/Block/Widget/Tabs.php +++ b/app/code/Magento/Backend/Block/Widget/Tabs.php @@ -114,6 +114,7 @@ public function addTab($tabId, $tab) if (empty($tabId)) { throw new \Exception(__('Please correct the tab configuration and try again. Tab Id should be not empty')); } + if (is_array($tab)) { $this->_tabs[$tabId] = new \Magento\Framework\DataObject($tab); } elseif ($tab instanceof \Magento\Framework\DataObject) { @@ -123,6 +124,7 @@ public function addTab($tabId, $tab) } } elseif (is_string($tab)) { $this->_addTabByName($tab, $tabId); + if (!$this->_tabs[$tabId] instanceof TabInterface) { unset($this->_tabs[$tabId]); return $this; @@ -130,6 +132,7 @@ public function addTab($tabId, $tab) } else { throw new \Exception(__('Please correct the tab configuration and try again.')); } + if ($this->_tabs[$tabId]->getUrl() === null) { $this->_tabs[$tabId]->setUrl('#'); } @@ -140,10 +143,7 @@ public function addTab($tabId, $tab) $this->_tabs[$tabId]->setId($tabId); $this->_tabs[$tabId]->setTabId($tabId); - - if ($this->_activeTab === null) { - $this->_activeTab = $tabId; - } + if (true === $this->_tabs[$tabId]->getActive()) { $this->setActiveTab($tabId); } @@ -232,33 +232,109 @@ protected function _setActiveTab($tabId) */ protected function _beforeToHtml() { + $this->_tabs = $this->reorderTabs(); + if ($activeTab = $this->getRequest()->getParam('active_tab')) { $this->setActiveTab($activeTab); } elseif ($activeTabId = $this->_authSession->getActiveTabId()) { $this->_setActiveTab($activeTabId); } - $_new = []; + if ($this->_activeTab === null && !empty($this->_tabs)) { + /** @var TabInterface $tab */ + $tab = reset($this->_tabs); + $this->_activeTab = $tab->getId(); + } + + $this->assign('tabs', $this->_tabs); + return parent::_beforeToHtml(); + } + + /** + * Reorder the tabs. + * + * @return array + */ + private function reorderTabs() + { + $orderByIdentity = []; + $orderByPosition = []; + $position = 100; + + /** + * Set the initial positions for each tab. + * + * @var string $key + * @var TabInterface $tab + */ foreach ($this->_tabs as $key => $tab) { - foreach ($this->_tabs as $k => $t) { - if ($t->getAfter() == $key) { - $_new[$key] = $tab; - $_new[$k] = $t; - } else { - if (!$tab->getAfter() || !in_array($tab->getAfter(), array_keys($this->_tabs))) { - $_new[$key] = $tab; - } - } - } + $tab->setPosition($position); + + $orderByIdentity[$key] = $tab; + $orderByPosition[$position] = $tab; + + $position += 100; } - $this->_tabs = $_new; - unset($_new); + return $this->applyTabsCorrectOrder($orderByPosition, $orderByIdentity); + } + + /** + * @param array $orderByPosition + * @param array $orderByIdentity + * + * @return array + */ + private function applyTabsCorrectOrder(array $orderByPosition, array $orderByIdentity) + { + $positionFactor = 1; + + /** + * Rearrange the positions by using the after tag for each tab. + * + * @var integer $position + * @var TabInterface $tab + */ + foreach ($orderByPosition as $position => $tab) { + if (!$tab->getAfter() || !in_array($tab->getAfter(), array_keys($orderByIdentity))) { + $positionFactor = 1; + continue; + } + + $grandPosition = $orderByIdentity[$tab->getAfter()]->getPosition(); + $newPosition = $grandPosition + $positionFactor; - $this->assign('tabs', $this->_tabs); - return parent::_beforeToHtml(); + unset($orderByPosition[$position]); + $orderByPosition[$newPosition] = $tab; + $tab->setPosition($newPosition); + + $positionFactor++; + } + + return $this->finalTabsSortOrder($orderByPosition); } + /** + * Apply the last sort order to tabs. + * + * @param array $orderByPosition + * + * @return array + */ + private function finalTabsSortOrder(array $orderByPosition) + { + ksort($orderByPosition); + + $ordered = []; + + /** @var TabInterface $tab */ + foreach ($orderByPosition as $tab) { + $ordered[$tab->getId()] = $tab; + } + + return $ordered; + } + /** * @return string */ diff --git a/app/code/Magento/Backend/Controller/Adminhtml/System/Account/Save.php b/app/code/Magento/Backend/Controller/Adminhtml/System/Account/Save.php index ac73d3629083a..01fa9c7c8257f 100644 --- a/app/code/Magento/Backend/Controller/Adminhtml/System/Account/Save.php +++ b/app/code/Magento/Backend/Controller/Adminhtml/System/Account/Save.php @@ -50,9 +50,9 @@ public function execute() $user = $this->_objectManager->create('Magento\User\Model\User')->load($userId); $user->setId($userId) - ->setUsername($this->getRequest()->getParam('username', false)) - ->setFirstname($this->getRequest()->getParam('firstname', false)) - ->setLastname($this->getRequest()->getParam('lastname', false)) + ->setUserName($this->getRequest()->getParam('username', false)) + ->setFirstName($this->getRequest()->getParam('firstname', false)) + ->setLastName($this->getRequest()->getParam('lastname', false)) ->setEmail(strtolower($this->getRequest()->getParam('email', false))); if ($this->_objectManager->get('Magento\Framework\Validator\Locale')->isValid($interfaceLocale)) { diff --git a/app/code/Magento/Backend/view/adminhtml/templates/page/header.phtml b/app/code/Magento/Backend/view/adminhtml/templates/page/header.phtml index 0d88328e52d8a..3162bda8daaf1 100644 --- a/app/code/Magento/Backend/view/adminhtml/templates/page/header.phtml +++ b/app/code/Magento/Backend/view/adminhtml/templates/page/header.phtml @@ -29,7 +29,7 @@ data-mage-init='{"dropdown":{}}' data-toggle="dropdown"> - escapeHtml($block->getUser()->getUsername()); ?> + escapeHtml($block->getUser()->getUserName()); ?>