Skip to content

Commit f449c16

Browse files
committed
Merge remote-tracking branch 'origin/2.3-develop' into 2.3-develop-pr74
2 parents 0763b68 + d354290 commit f449c16

File tree

56 files changed

+1554
-691
lines changed

Some content is hidden

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

56 files changed

+1554
-691
lines changed

app/code/Magento/Captcha/Observer/CheckContactUsFormObserver.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
use Magento\Framework\App\Request\DataPersistorInterface;
1010
use Magento\Framework\App\ObjectManager;
1111

12+
/**
13+
* Class CheckContactUsFormObserver
14+
*/
1215
class CheckContactUsFormObserver implements ObserverInterface
1316
{
1417
/**
@@ -76,7 +79,7 @@ public function execute(\Magento\Framework\Event\Observer $observer)
7679
/** @var \Magento\Framework\App\Action\Action $controller */
7780
$controller = $observer->getControllerAction();
7881
if (!$captcha->isCorrect($this->captchaStringResolver->resolve($controller->getRequest(), $formId))) {
79-
$this->messageManager->addError(__('Incorrect CAPTCHA.'));
82+
$this->messageManager->addErrorMessage(__('Incorrect CAPTCHA.'));
8083
$this->getDataPersistor()->set($formId, $controller->getRequest()->getPostValue());
8184
$this->_actionFlag->set('', \Magento\Framework\App\Action\Action::FLAG_NO_DISPATCH, true);
8285
$this->redirect->redirect($controller->getResponse(), 'contact/index/index');

app/code/Magento/Captcha/Observer/CheckForgotpasswordObserver.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77

88
use Magento\Framework\Event\ObserverInterface;
99

10+
/**
11+
* Class CheckForgotpasswordObserver
12+
*/
1013
class CheckForgotpasswordObserver implements ObserverInterface
1114
{
1215
/**
@@ -69,7 +72,7 @@ public function execute(\Magento\Framework\Event\Observer $observer)
6972
/** @var \Magento\Framework\App\Action\Action $controller */
7073
$controller = $observer->getControllerAction();
7174
if (!$captchaModel->isCorrect($this->captchaStringResolver->resolve($controller->getRequest(), $formId))) {
72-
$this->messageManager->addError(__('Incorrect CAPTCHA'));
75+
$this->messageManager->addErrorMessage(__('Incorrect CAPTCHA'));
7376
$this->_actionFlag->set('', \Magento\Framework\App\Action\Action::FLAG_NO_DISPATCH, true);
7477
$this->redirect->redirect($controller->getResponse(), '*/*/forgotpassword');
7578
}

app/code/Magento/Captcha/Observer/CheckUserCreateObserver.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77

88
use Magento\Framework\Event\ObserverInterface;
99

10+
/**
11+
* Class CheckUserCreateObserver
12+
*
13+
* @SuppressWarnings(PHPMD.CookieAndSessionMisuse)
14+
*/
1015
class CheckUserCreateObserver implements ObserverInterface
1116
{
1217
/**
@@ -86,7 +91,7 @@ public function execute(\Magento\Framework\Event\Observer $observer)
8691
/** @var \Magento\Framework\App\Action\Action $controller */
8792
$controller = $observer->getControllerAction();
8893
if (!$captchaModel->isCorrect($this->captchaStringResolver->resolve($controller->getRequest(), $formId))) {
89-
$this->messageManager->addError(__('Incorrect CAPTCHA'));
94+
$this->messageManager->addErrorMessage(__('Incorrect CAPTCHA'));
9095
$this->_actionFlag->set('', \Magento\Framework\App\Action\Action::FLAG_NO_DISPATCH, true);
9196
$this->_session->setCustomerFormData($controller->getRequest()->getPostValue());
9297
$url = $this->_urlManager->getUrl('*/*/create', ['_nosecret' => true]);

app/code/Magento/Captcha/Observer/CheckUserEditObserver.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,12 @@
1111
use Magento\Framework\App\Config\ScopeConfigInterface;
1212

1313
/**
14-
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
14+
* Class CheckUserEditObserver
15+
*
16+
* @SuppressWarnings(PHPMD.CookieAndSessionMisuse)
1517
*/
1618
class CheckUserEditObserver implements ObserverInterface
1719
{
18-
/**
19-
* Form ID
20-
*/
2120
const FORM_ID = 'user_edit';
2221

2322
/**
@@ -96,7 +95,8 @@ public function __construct(
9695
* Check Captcha On Forgot Password Page
9796
*
9897
* @param \Magento\Framework\Event\Observer $observer
99-
* @return $this
98+
* @return $this|void
99+
* @throws \Magento\Framework\Exception\SessionException
100100
*/
101101
public function execute(\Magento\Framework\Event\Observer $observer)
102102
{
@@ -119,9 +119,9 @@ public function execute(\Magento\Framework\Event\Observer $observer)
119119
'The account is locked. Please wait and try again or contact %1.',
120120
$this->scopeConfig->getValue('contact/email/recipient_email')
121121
);
122-
$this->messageManager->addError($message);
122+
$this->messageManager->addErrorMessage($message);
123123
}
124-
$this->messageManager->addError(__('Incorrect CAPTCHA'));
124+
$this->messageManager->addErrorMessage(__('Incorrect CAPTCHA'));
125125
$this->actionFlag->set('', \Magento\Framework\App\Action\Action::FLAG_NO_DISPATCH, true);
126126
$this->redirect->redirect($controller->getResponse(), '*/*/edit');
127127
}

app/code/Magento/Captcha/Observer/CheckUserForgotPasswordBackendObserver.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77

88
use Magento\Framework\Event\ObserverInterface;
99

10+
/**
11+
* Class CheckUserForgotPasswordBackendObserver
12+
*
13+
* @SuppressWarnings(PHPMD.CookieAndSessionMisuse)
14+
*/
1015
class CheckUserForgotPasswordBackendObserver implements ObserverInterface
1116
{
1217
/**
@@ -76,7 +81,7 @@ public function execute(\Magento\Framework\Event\Observer $observer)
7681
) {
7782
$this->_session->setEmail((string)$controller->getRequest()->getPost('email'));
7883
$this->_actionFlag->set('', \Magento\Framework\App\Action\Action::FLAG_NO_DISPATCH, true);
79-
$this->messageManager->addError(__('Incorrect CAPTCHA'));
84+
$this->messageManager->addErrorMessage(__('Incorrect CAPTCHA'));
8085
$controller->getResponse()->setRedirect(
8186
$controller->getUrl('*/*/forgotpassword', ['_nosecret' => true])
8287
);

app/code/Magento/Captcha/Observer/CheckUserLoginObserver.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66

77
namespace Magento\Captcha\Observer;
88

9+
use Magento\Customer\Api\CustomerRepositoryInterface;
910
use Magento\Customer\Model\AuthenticationInterface;
1011
use Magento\Framework\Event\ObserverInterface;
1112
use Magento\Framework\Exception\NoSuchEntityException;
12-
use Magento\Customer\Api\CustomerRepositoryInterface;
1313

1414
/**
1515
* Check captcha on user login page observer.
@@ -64,6 +64,8 @@ class CheckUserLoginObserver implements ObserverInterface
6464
protected $authentication;
6565

6666
/**
67+
* CheckUserLoginObserver constructor.
68+
*
6769
* @param \Magento\Captcha\Helper\Data $helper
6870
* @param \Magento\Framework\App\ActionFlag $actionFlag
6971
* @param \Magento\Framework\Message\ManagerInterface $messageManager
@@ -125,8 +127,7 @@ private function getAuthentication()
125127
* Check captcha on user login page
126128
*
127129
* @param \Magento\Framework\Event\Observer $observer
128-
* @throws NoSuchEntityException
129-
* @return $this
130+
* @return $this|void
130131
*/
131132
public function execute(\Magento\Framework\Event\Observer $observer)
132133
{
@@ -143,10 +144,11 @@ public function execute(\Magento\Framework\Event\Observer $observer)
143144
try {
144145
$customer = $this->getCustomerRepository()->get($login);
145146
$this->getAuthentication()->processAuthenticationFailure($customer->getId());
147+
// phpcs:ignore Magento2.CodeAnalysis.EmptyBlock
146148
} catch (NoSuchEntityException $e) {
147149
//do nothing as customer existence is validated later in authenticate method
148150
}
149-
$this->messageManager->addError(__('Incorrect CAPTCHA'));
151+
$this->messageManager->addErrorMessage(__('Incorrect CAPTCHA'));
150152
$this->_actionFlag->set('', \Magento\Framework\App\Action\Action::FLAG_NO_DISPATCH, true);
151153
$this->_session->setUsername($login);
152154
$beforeUrl = $this->_session->getBeforeAuthUrl();

app/code/Magento/Captcha/Test/Unit/Observer/CheckContactUsFormObserverTest.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,10 @@ protected function setUp()
6969
$this->messageManagerMock = $this->createMock(\Magento\Framework\Message\ManagerInterface::class);
7070
$this->redirectMock = $this->createMock(\Magento\Framework\App\Response\RedirectInterface::class);
7171
$this->captchaStringResolverMock = $this->createMock(\Magento\Captcha\Observer\CaptchaStringResolver::class);
72-
$this->sessionMock = $this->createPartialMock(\Magento\Framework\Session\SessionManager::class, ['addError']);
72+
$this->sessionMock = $this->createPartialMock(
73+
\Magento\Framework\Session\SessionManager::class,
74+
['addErrorMessage']
75+
);
7376
$this->dataPersistorMock = $this->getMockBuilder(\Magento\Framework\App\Request\DataPersistorInterface::class)
7477
->getMockForAbstractClass();
7578

@@ -116,7 +119,7 @@ public function testCheckContactUsFormWhenCaptchaIsRequiredAndValid()
116119
$this->helperMock->expects($this->any())
117120
->method('getCaptcha')
118121
->with($formId)->willReturn($this->captchaMock);
119-
$this->sessionMock->expects($this->never())->method('addError');
122+
$this->sessionMock->expects($this->never())->method('addErrorMessage');
120123

121124
$this->checkContactUsFormObserver->execute(
122125
new \Magento\Framework\Event\Observer(['controller_action' => $controller])
@@ -163,7 +166,7 @@ public function testCheckContactUsFormRedirectsCustomerWithWarningMessageWhenCap
163166
->method('getCaptcha')
164167
->with($formId)
165168
->willReturn($this->captchaMock);
166-
$this->messageManagerMock->expects($this->once())->method('addError')->with($warningMessage);
169+
$this->messageManagerMock->expects($this->once())->method('addErrorMessage')->with($warningMessage);
167170
$this->actionFlagMock->expects($this->once())
168171
->method('set')
169172
->with('', \Magento\Framework\App\Action\Action::FLAG_NO_DISPATCH, true);

app/code/Magento/Captcha/Test/Unit/Observer/CheckForgotpasswordObserverTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ public function testCheckForgotpasswordRedirects()
138138
)->will(
139139
$this->returnValue($this->_captcha)
140140
);
141-
$this->_messageManager->expects($this->once())->method('addError')->with($warningMessage);
141+
$this->_messageManager->expects($this->once())->method('addErrorMessage')->with($warningMessage);
142142
$this->_actionFlag->expects(
143143
$this->once()
144144
)->method(

app/code/Magento/Captcha/Test/Unit/Observer/CheckUserCreateObserverTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ public function testCheckUserCreateRedirectsError()
151151
)->will(
152152
$this->returnValue($this->_captcha)
153153
);
154-
$this->_messageManager->expects($this->once())->method('addError')->with($warningMessage);
154+
$this->_messageManager->expects($this->once())->method('addErrorMessage')->with($warningMessage);
155155
$this->_actionFlag->expects(
156156
$this->once()
157157
)->method(

app/code/Magento/Captcha/Test/Unit/Observer/CheckUserEditObserverTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ public function testExecute()
146146

147147
$message = __('The account is locked. Please wait and try again or contact %1.', $email);
148148
$this->messageManagerMock->expects($this->exactly(2))
149-
->method('addError')
149+
->method('addErrorMessage')
150150
->withConsecutive([$message], [__('Incorrect CAPTCHA')]);
151151

152152
$this->actionFlagMock->expects($this->once())

app/code/Magento/Captcha/Test/Unit/Observer/CheckUserLoginObserverTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ public function testExecute()
145145
->with($customerId);
146146

147147
$this->messageManagerMock->expects($this->once())
148-
->method('addError')
148+
->method('addErrorMessage')
149149
->with(__('Incorrect CAPTCHA'));
150150

151151
$this->actionFlagMock->expects($this->once())

app/code/Magento/Catalog/Block/Widget/Link.php

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,15 @@
44
* See COPYING.txt for license details.
55
*/
66

7-
/**
8-
* Widget to display catalog link
9-
*
10-
* @author Magento Core Team <[email protected]>
11-
*/
127
namespace Magento\Catalog\Block\Widget;
138

149
use Magento\CatalogUrlRewrite\Model\ProductUrlRewriteGenerator;
1510
use Magento\UrlRewrite\Model\UrlFinderInterface;
1611
use Magento\UrlRewrite\Service\V1\Data\UrlRewrite;
1712

13+
/**
14+
* Render the URL of given entity
15+
*/
1816
class Link extends \Magento\Framework\View\Element\Html\Link implements \Magento\Widget\Block\BlockInterface
1917
{
2018
/**
@@ -63,10 +61,9 @@ public function __construct(
6361

6462
/**
6563
* Prepare url using passed id path and return it
66-
* or return false if path was not found in url rewrites.
6764
*
6865
* @throws \RuntimeException
69-
* @return string|false
66+
* @return string|false if path was not found in url rewrites.
7067
* @SuppressWarnings(PHPMD.NPathComplexity)
7168
*/
7269
public function getHref()
@@ -93,7 +90,7 @@ public function getHref()
9390
if ($rewrite) {
9491
$href = $store->getUrl('', ['_direct' => $rewrite->getRequestPath()]);
9592

96-
if (strpos($href, '___store') === false) {
93+
if ($this->addStoreCodeParam($store, $href)) {
9794
$href .= (strpos($href, '?') === false ? '?' : '&') . '___store=' . $store->getCode();
9895
}
9996
}
@@ -102,6 +99,22 @@ public function getHref()
10299
return $this->_href;
103100
}
104101

102+
/**
103+
* Checks whether store code query param should be appended to the URL
104+
*
105+
* @param \Magento\Store\Model\Store $store
106+
* @param string $url
107+
* @return bool
108+
* @throws \Magento\Framework\Exception\NoSuchEntityException
109+
*/
110+
private function addStoreCodeParam(\Magento\Store\Model\Store $store, string $url): bool
111+
{
112+
return $this->getStoreId()
113+
&& !$store->isUseStoreInUrl()
114+
&& $store->getId() !== $this->_storeManager->getStore()->getId()
115+
&& strpos($url, '___store') === false;
116+
}
117+
105118
/**
106119
* Parse id_path
107120
*
@@ -121,6 +134,7 @@ protected function parseIdPath($idPath)
121134

122135
/**
123136
* Prepare label using passed text as parameter.
137+
*
124138
* If anchor text was not specified get entity name from DB.
125139
*
126140
* @return string
@@ -150,9 +164,8 @@ public function getLabel()
150164

151165
/**
152166
* Render block HTML
153-
* or return empty string if url can't be prepared
154167
*
155-
* @return string
168+
* @return string empty string if url can't be prepared
156169
*/
157170
protected function _toHtml()
158171
{

app/code/Magento/Catalog/Test/Mftf/Test/AdminAddImageToWYSIWYGProductTest.xml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@
1616
<description value="Admin should be able to add image to WYSIWYG Editor on Product Page"/>
1717
<severity value="CRITICAL"/>
1818
<testCaseId value="MAGETWO-84375"/>
19-
<skip>
20-
<issueId value="MC-17232"/>
21-
</skip>
2219
</annotations>
2320
<before>
2421
<actionGroup ref="LoginActionGroup" stepKey="login"/>
@@ -78,6 +75,8 @@
7875
<waitForLoadingMaskToDisappear stepKey="waitForLoading13"/>
7976
<see selector="{{ProductShortDescriptionWYSIWYGToolbarSection.CreateFolder}}" userInput="Create Folder" stepKey="seeCreateFolderBtn2" />
8077
<waitForLoadingMaskToDisappear stepKey="waitForLoading14"/>
78+
<click userInput="Storage Root" stepKey="clickOnRootFolder" />
79+
<waitForLoadingMaskToDisappear stepKey="waitForLoading15"/>
8180
<dontSeeElement selector="{{ProductShortDescriptionWYSIWYGToolbarSection.InsertFile}}" stepKey="dontSeeAddSelectedBtn3" />
8281
<attachFile selector="{{ProductShortDescriptionWYSIWYGToolbarSection.BrowseUploadImage}}" userInput="{{ImageUpload3.value}}" stepKey="uploadImage3"/>
8382
<waitForLoadingMaskToDisappear stepKey="waitForFileUpload3"/>

0 commit comments

Comments
 (0)