Skip to content

Commit d816d66

Browse files
authored
Merge pull request #4859 from magento-mpi/MPI-PR-10032019
MPI-PR-2019-10-03
2 parents 5f1a803 + f74bbf3 commit d816d66

File tree

6 files changed

+242
-21
lines changed

6 files changed

+242
-21
lines changed

app/code/Magento/Backend/Model/Locale/Resolver.php

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

88
/**
99
* Backend locale model
10+
*
1011
* @api
1112
* @since 100.0.2
13+
* @SuppressWarnings(PHPMD.CookieAndSessionMisuse)
1214
*/
1315
class Resolver extends \Magento\Framework\Locale\Resolver
1416
{
@@ -40,7 +42,7 @@ class Resolver extends \Magento\Framework\Locale\Resolver
4042
* @param Manager $localeManager
4143
* @param \Magento\Framework\App\RequestInterface $request
4244
* @param \Magento\Framework\Validator\Locale $localeValidator
43-
* @param null $locale
45+
* @param string|null $locale
4446
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
4547
*/
4648
public function __construct(
@@ -76,7 +78,7 @@ public function setLocale($locale = null)
7678
$sessionLocale = $this->_session->getSessionLocale();
7779
$userLocale = $this->_localeManager->getUserInterfaceLocale();
7880

79-
$localeCodes = array_filter([$forceLocale, $sessionLocale, $userLocale]);
81+
$localeCodes = array_filter([$forceLocale, $locale, $sessionLocale, $userLocale]);
8082

8183
if (count($localeCodes)) {
8284
$locale = reset($localeCodes);

app/code/Magento/PaypalCaptcha/view/frontend/web/js/view/payment/list-mixin.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,16 @@ define([
3434

3535
/**
3636
* Overrides default window.clearTimeout() to catch errors from iframe and reload Captcha.
37+
*
38+
* @param {Number} timeoutID
3739
*/
38-
clearTimeout: function () {
40+
clearTimeout: function (timeoutID) {
3941
var captcha = captchaList.getCaptchaByFormId(this.formId);
4042

4143
if (captcha !== null) {
4244
captcha.refresh();
4345
}
44-
clearTimeout();
46+
clearTimeout(timeoutID);
4547
}
4648
};
4749

app/code/Magento/Store/App/FrontController/Plugin/RequestPreprocessor.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
*/
66
namespace Magento\Store\App\FrontController\Plugin;
77

8+
/**
9+
* Class RequestPreprocessor
10+
*/
811
class RequestPreprocessor
912
{
1013
/**
@@ -52,6 +55,7 @@ public function __construct(
5255

5356
/**
5457
* Auto-redirect to base url (without SID) if the requested url doesn't match it.
58+
*
5559
* By default this feature is enabled in configuration.
5660
*
5761
* @param \Magento\Framework\App\FrontController $subject
@@ -72,10 +76,11 @@ public function aroundDispatch(
7276
$this->_storeManager->getStore()->isCurrentlySecure()
7377
);
7478
if ($baseUrl) {
79+
// phpcs:disable Magento2.Functions.DiscouragedFunction
7580
$uri = parse_url($baseUrl);
7681
if (!$this->getBaseUrlChecker()->execute($uri, $request)) {
7782
$redirectUrl = $this->_url->getRedirectUrl(
78-
$this->_url->getUrl(ltrim($request->getPathInfo(), '/'), ['_nosid' => true])
83+
$this->_url->getDirectUrl(ltrim($request->getPathInfo(), '/'), ['_nosid' => true])
7984
);
8085
$redirectCode = (int)$this->_scopeConfig->getValue(
8186
'web/url/redirect_to_base',

app/design/adminhtml/Magento/backend/Magento_Banner/web/css/source/_module.less

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ input[type='checkbox'].banner-content-checkbox {
2424
}
2525

2626
.adminhtml-widget_instance-edit,
27+
.adminhtml-cms_page-edit,
2728
.adminhtml-banner-edit {
2829
.admin__fieldset {
2930
.admin__field-control {

dev/tests/integration/testsuite/Magento/Backend/Model/Locale/ResolverTest.php

Lines changed: 40 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ class ResolverTest extends \PHPUnit\Framework\TestCase
2020
*/
2121
protected $_model;
2222

23+
/**
24+
* {@inheritDoc}
25+
*/
2326
protected function setUp()
2427
{
2528
parent::setUp();
@@ -29,15 +32,15 @@ protected function setUp()
2932
}
3033

3134
/**
32-
* @covers \Magento\Backend\Model\Locale\Resolver::setLocale
35+
* Tests setLocale() with default locale
3336
*/
3437
public function testSetLocaleWithDefaultLocale()
3538
{
3639
$this->_checkSetLocale(Resolver::DEFAULT_LOCALE);
3740
}
3841

3942
/**
40-
* @covers \Magento\Backend\Model\Locale\Resolver::setLocale
43+
* Tests setLocale() with interface locale
4144
*/
4245
public function testSetLocaleWithBaseInterfaceLocale()
4346
{
@@ -55,7 +58,7 @@ public function testSetLocaleWithBaseInterfaceLocale()
5558
}
5659

5760
/**
58-
* @covers \Magento\Backend\Model\Locale\Resolver::setLocale
61+
* Tests setLocale() with session locale
5962
*/
6063
public function testSetLocaleWithSessionLocale()
6164
{
@@ -68,7 +71,7 @@ public function testSetLocaleWithSessionLocale()
6871
}
6972

7073
/**
71-
* @covers \Magento\Backend\Model\Locale\Resolver::setLocale
74+
* Tests setLocale() with post parameter
7275
*/
7376
public function testSetLocaleWithRequestLocale()
7477
{
@@ -78,13 +81,45 @@ public function testSetLocaleWithRequestLocale()
7881
$this->_checkSetLocale('de_DE');
7982
}
8083

84+
/**
85+
* Tests setLocale() with parameter
86+
*
87+
* @param string|null $localeParam
88+
* @param string|null $localeRequestParam
89+
* @param string $localeExpected
90+
* @dataProvider setLocaleWithParameterDataProvider
91+
*/
92+
public function testSetLocaleWithParameter(
93+
?string $localeParam,
94+
?string $localeRequestParam,
95+
string $localeExpected
96+
) {
97+
$request = Bootstrap::getObjectManager()
98+
->get(\Magento\Framework\App\RequestInterface::class);
99+
$request->setPostValue(['locale' => $localeRequestParam]);
100+
$this->_model->setLocale($localeParam);
101+
$this->assertEquals($localeExpected, $this->_model->getLocale());
102+
}
103+
104+
/**
105+
* @return array
106+
*/
107+
public function setLocaleWithParameterDataProvider(): array
108+
{
109+
return [
110+
['ko_KR', 'ja_JP', 'ja_JP'],
111+
['ko_KR', null, 'ko_KR'],
112+
[null, 'ja_JP', 'ja_JP'],
113+
];
114+
}
115+
81116
/**
82117
* Check set locale
83118
*
84119
* @param string $localeCodeToCheck
85120
* @return void
86121
*/
87-
protected function _checkSetLocale($localeCodeToCheck)
122+
private function _checkSetLocale($localeCodeToCheck)
88123
{
89124
$this->_model->setLocale();
90125
$localeCode = $this->_model->getLocale();

0 commit comments

Comments
 (0)