Skip to content

Commit ab4f367

Browse files
committed
Merge remote-tracking branch 'commerce/2.4-develop' into PWA-1654
2 parents de8f0e5 + dcbbe78 commit ab4f367

File tree

312 files changed

+9896
-4660
lines changed

Some content is hidden

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

312 files changed

+9896
-4660
lines changed

app/code/Magento/AdvancedPricingImportExport/Controller/Adminhtml/Export/GetFilter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ public function execute()
3434
/** @var $export \Magento\ImportExport\Model\Export */
3535
$export = $this->_objectManager->create(\Magento\ImportExport\Model\Export::class);
3636
$export->setData($data);
37-
$attrFilterBlock->prepareCollection(
38-
$export->filterAttributeCollection($export->getEntityAttributeCollection())
37+
$export->filterAttributeCollection(
38+
$attrFilterBlock->prepareCollection($export->getEntityAttributeCollection())
3939
);
4040
return $resultLayout;
4141
} catch (\Exception $e) {

app/code/Magento/Analytics/Test/Mftf/Test/AdminAdvancedReportingButtonTest.xml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,12 @@
99
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
1010
<test name="AdminAdvancedReportingButtonTest">
1111
<annotations>
12-
<stories value="AdvancedReporting"/>
13-
<title value="AdvancedReportingButtonTest"/>
14-
<description value="Test log in to AdvancedReporting and tests AdvancedReportingButtonTest"/>
15-
<testCaseId value="MC-14800"/>
16-
<skip>
17-
<issueId value="MC-14800" />
18-
</skip>
12+
<features value="Analytics"/>
13+
<stories value="Advanced Reporting"/>
14+
<title value="Assert the Advanced Reporting page is opened by dashboard link"/>
15+
<description value="Check the ability to navigate to the Advanced Reporting page through the Advanced Reporting button on the dashboard"/>
1916
<severity value="CRITICAL"/>
17+
<testCaseId value="MC-28376"/>
2018
<group value="analytics"/>
2119
<group value="mtf_migrated"/>
2220
</annotations>

app/code/Magento/Backend/App/Action/Plugin/Authentication.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,8 +225,10 @@ protected function _redirectIfNeededAfterLogin(\Magento\Framework\App\RequestInt
225225

226226
// Checks, whether secret key is required for admin access or request uri is explicitly set
227227
if ($this->_url->useSecretKey()) {
228-
$requestParts = explode('/', trim($request->getRequestUri(), '/'), 2);
229-
$requestUri = $this->_url->getUrl(array_pop($requestParts));
228+
$requestParts = explode('/', trim($request->getRequestUri(), '/'), 3);
229+
$baseUrlPath = trim(parse_url($this->backendUrl->getBaseUrl(), PHP_URL_PATH), '/');
230+
$routeIndex = empty($baseUrlPath) ? 0 : 1;
231+
$requestUri = $this->_url->getUrl($requestParts[$routeIndex]);
230232
} elseif ($request) {
231233
$requestUri = $request->getRequestUri();
232234
}

app/code/Magento/Backend/Block/Dashboard/Bar.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66
namespace Magento\Backend\Block\Dashboard;
77

8+
use Magento\Directory\Model\Currency;
89
use Magento\Store\Model\Store;
910

1011
/**
@@ -20,10 +21,15 @@ class Bar extends \Magento\Backend\Block\Dashboard\AbstractDashboard
2021
protected $_totals = [];
2122

2223
/**
23-
* @var \Magento\Directory\Model\Currency|null
24+
* @var Currency|null
2425
*/
2526
protected $_currentCurrencyCode = null;
2627

28+
/**
29+
* @var Currency
30+
*/
31+
private $_currency;
32+
2733
/**
2834
* Get totals
2935
*
@@ -67,7 +73,7 @@ public function format($price)
6773
/**
6874
* Setting currency model
6975
*
70-
* @param \Magento\Directory\Model\Currency $currency
76+
* @param Currency $currency
7177
* @return void
7278
*/
7379
public function setCurrency($currency)
@@ -78,7 +84,7 @@ public function setCurrency($currency)
7884
/**
7985
* Retrieve currency model if not set then return currency model for current store
8086
*
81-
* @return \Magento\Directory\Model\Currency
87+
* @return Currency
8288
* @SuppressWarnings(PHPMD.RequestAwareBlockMethod)
8389
*/
8490
public function getCurrency()

app/code/Magento/Backend/Controller/Adminhtml/Auth/Login.php

Lines changed: 62 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
<?php
22
/**
3-
*
43
* Copyright © Magento, Inc. All rights reserved.
54
* See COPYING.txt for license details.
65
*/
76
namespace Magento\Backend\Controller\Adminhtml\Auth;
87

8+
use Magento\Backend\App\Area\FrontNameResolver;
9+
use Magento\Backend\App\BackendAppList;
10+
use Magento\Backend\Model\UrlFactory;
911
use Magento\Framework\App\Action\HttpGetActionInterface as HttpGet;
1012
use Magento\Framework\App\Action\HttpPostActionInterface as HttpPost;
13+
use Magento\Framework\App\ObjectManager;
14+
use Magento\Framework\App\Request\Http;
1115

1216
/**
1317
* @api
@@ -20,18 +24,50 @@ class Login extends \Magento\Backend\Controller\Adminhtml\Auth implements HttpGe
2024
*/
2125
protected $resultPageFactory;
2226

27+
/**
28+
* @var FrontNameResolver
29+
*/
30+
private $frontNameResolver;
31+
32+
/**
33+
* @var BackendAppList
34+
*/
35+
private $backendAppList;
36+
37+
/**
38+
* @var UrlFactory
39+
*/
40+
private $backendUrlFactory;
41+
42+
/**
43+
* @var Http
44+
*/
45+
private $http;
46+
2347
/**
2448
* Constructor
2549
*
2650
* @param \Magento\Backend\App\Action\Context $context
2751
* @param \Magento\Framework\View\Result\PageFactory $resultPageFactory
52+
* @param FrontNameResolver|null $frontNameResolver
53+
* @param BackendAppList|null $backendAppList
54+
* @param UrlFactory|null $backendUrlFactory
55+
* @param Http|null $http
2856
*/
2957
public function __construct(
3058
\Magento\Backend\App\Action\Context $context,
31-
\Magento\Framework\View\Result\PageFactory $resultPageFactory
59+
\Magento\Framework\View\Result\PageFactory $resultPageFactory,
60+
FrontNameResolver $frontNameResolver = null,
61+
BackendAppList $backendAppList = null,
62+
UrlFactory $backendUrlFactory = null,
63+
Http $http = null
3264
) {
3365
$this->resultPageFactory = $resultPageFactory;
3466
parent::__construct($context);
67+
$this->frontNameResolver = $frontNameResolver ?? ObjectManager::getInstance()->get(FrontNameResolver::class);
68+
$this->backendAppList = $backendAppList ?? ObjectManager::getInstance()->get(BackendAppList::class);
69+
$this->backendUrlFactory = $backendUrlFactory ?? ObjectManager::getInstance()->get(UrlFactory::class);
70+
$this->http = $http ?? ObjectManager::getInstance()->get(Http::class);
3571
}
3672

3773
/**
@@ -49,7 +85,8 @@ public function execute()
4985
}
5086

5187
$requestUrl = $this->getRequest()->getUri();
52-
if (!$requestUrl->isValid()) {
88+
89+
if (!$requestUrl->isValid() || !$this->isValidBackendUri()) {
5390
return $this->getRedirect($this->getUrl('*'));
5491
}
5592

@@ -69,4 +106,26 @@ private function getRedirect($path)
69106
$resultRedirect->setPath($path);
70107
return $resultRedirect;
71108
}
109+
110+
/**
111+
* Verify if correct backend uri requested.
112+
*
113+
* @return bool
114+
*/
115+
private function isValidBackendUri(): bool
116+
{
117+
$requestUri = $this->getRequest()->getRequestUri();
118+
$backendApp = $this->backendAppList->getCurrentApp();
119+
$baseUrl = parse_url($this->backendUrlFactory->create()->getBaseUrl(), PHP_URL_PATH);
120+
if (!$backendApp) {
121+
$backendFrontName = $this->frontNameResolver->getFrontName();
122+
} else {
123+
//In case of application authenticating through the admin login, the script name should be removed
124+
//from the path, because application has own script.
125+
$baseUrl = $this->http->getUrlNoScript($baseUrl);
126+
$backendFrontName = $backendApp->getCookiePath();
127+
}
128+
129+
return strpos($requestUri, $baseUrl . $backendFrontName) === 0;
130+
}
72131
}

app/code/Magento/Backend/Controller/Adminhtml/Dashboard/RefreshStatistics.php

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,33 @@
66

77
namespace Magento\Backend\Controller\Adminhtml\Dashboard;
88

9+
use Magento\Backend\App\Action\Context;
910
use Magento\Framework\App\Action\HttpPostActionInterface;
11+
use Magento\Framework\Stdlib\DateTime\Filter\Date;
1012
use Magento\Reports\Controller\Adminhtml\Report\Statistics;
13+
use Psr\Log\LoggerInterface;
1114

1215
/**
1316
* Refresh Dashboard statistics action.
1417
*/
1518
class RefreshStatistics extends Statistics implements HttpPostActionInterface
1619
{
1720
/**
18-
* @param \Magento\Backend\App\Action\Context $context
19-
* @param \Magento\Framework\Stdlib\DateTime\Filter\Date $dateFilter
21+
* @var LoggerInterface
22+
*/
23+
private $logger;
24+
25+
/**
26+
* @param Context $context
27+
* @param Date $dateFilter
2028
* @param array $reportTypes
21-
* @param \Psr\Log\LoggerInterface $logger
29+
* @param LoggerInterface $logger
2230
*/
2331
public function __construct(
24-
\Magento\Backend\App\Action\Context $context,
25-
\Magento\Framework\Stdlib\DateTime\Filter\Date $dateFilter,
32+
Context $context,
33+
Date $dateFilter,
2634
array $reportTypes,
27-
\Psr\Log\LoggerInterface $logger
35+
LoggerInterface $logger
2836
) {
2937
parent::__construct($context, $dateFilter, $reportTypes);
3038
$this->logger = $logger;

app/code/Magento/Backend/Model/Menu/Config.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,11 @@ class Config
6363
*/
6464
protected $_appState;
6565

66+
/**
67+
* @var Builder
68+
*/
69+
private $_menuBuilder;
70+
6671
/**
6772
* @param \Magento\Backend\Model\Menu\Builder $menuBuilder
6873
* @param \Magento\Backend\Model\Menu\AbstractDirector $menuDirector
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<entities xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:DataGenerator/etc/dataProfileSchema.xsd">
11+
<entity name="AdminEnableUrlRewritesConfigData">
12+
<data key="path">web/seo/use_rewrites</data>
13+
<data key="value">1</data>
14+
</entity>
15+
<entity name="AdminDisableUrlRewritesConfigData">
16+
<data key="path">web/seo/use_rewrites</data>
17+
<data key="value">0</data>
18+
</entity>
19+
</entities>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<entities xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:DataGenerator/etc/dataProfileSchema.xsd">
10+
<entity name="SystemUploadConfigurationMaxWidth">
11+
<data key="path">system/upload_configuration/max_width</data>
12+
<data key="value">1920</data>
13+
</entity>
14+
<entity name="SystemUploadConfigurationMaxHeight">
15+
<data key="path">system/upload_configuration/max_height</data>
16+
<data key="value">1200</data>
17+
</entity>
18+
</entities>
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
11+
<test name="AdminLoginSuccessfulWithRewritesDisabledTest">
12+
<annotations>
13+
<features value="Backend"/>
14+
<stories value="Login on the Admin Login page"/>
15+
<title
16+
value="Admin should be able to log into the Magento Admin backend successfully if url rewrites are disabled"/>
17+
<description
18+
value="Admin should be able to log into the Magento Admin backend successfully if url rewrites are disabled"/>
19+
<severity value="CRITICAL"/>
20+
<group value="example"/>
21+
<group value="login"/>
22+
</annotations>
23+
24+
<before>
25+
<magentoCLI command="config:set {{AdminDisableUrlRewritesConfigData.path}} {{AdminDisableUrlRewritesConfigData.value}}" stepKey="disableUrlRewrites"/>
26+
</before>
27+
<after>
28+
<magentoCLI command="config:set {{AdminEnableUrlRewritesConfigData.path}} {{AdminEnableUrlRewritesConfigData.value}}" stepKey="enableUrlRewrites"/>
29+
</after>
30+
31+
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
32+
<actionGroup ref="AssertAdminSuccessLoginActionGroup" stepKey="assertLoggedIn"/>
33+
<actionGroup ref="AdminLogoutActionGroup" stepKey="logoutFromAdmin"/>
34+
</test>
35+
</tests>

0 commit comments

Comments
 (0)