Skip to content

Commit 5fd6f12

Browse files
committed
Merge remote-tracking branch 'origin/MC-24840' into 2.4-develop-pr115
2 parents 11c704d + 62da7cb commit 5fd6f12

File tree

2 files changed

+56
-1
lines changed

2 files changed

+56
-1
lines changed

app/code/Magento/Backend/App/Area/FrontNameResolver.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,13 @@ public function isHostBackend()
123123
if ($this->scopeConfig->getValue(self::XML_PATH_USE_CUSTOM_ADMIN_URL, ScopeInterface::SCOPE_STORE)) {
124124
$backendUrl = $this->scopeConfig->getValue(self::XML_PATH_CUSTOM_ADMIN_URL, ScopeInterface::SCOPE_STORE);
125125
} else {
126-
$backendUrl = $this->scopeConfig->getValue(Store::XML_PATH_UNSECURE_BASE_URL, ScopeInterface::SCOPE_STORE);
126+
$backendUrl = $this->config->getValue(Store::XML_PATH_UNSECURE_BASE_URL);
127+
if ($backendUrl === null) {
128+
$backendUrl = $this->scopeConfig->getValue(
129+
Store::XML_PATH_UNSECURE_BASE_URL,
130+
ScopeInterface::SCOPE_STORE
131+
);
132+
}
127133
}
128134
$host = $this->request->getServer('HTTP_HOST', '');
129135
return stripos($this->getHostWithPort($backendUrl), (string) $host) !== false;
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
declare(strict_types=1);
8+
9+
namespace Magento\Backend\App\Area;
10+
11+
use PHPUnit\Framework\TestCase;
12+
use Magento\TestFramework\Helper\Bootstrap;
13+
14+
/**
15+
* @magentoAppArea adminhtml
16+
*/
17+
class FrontNameResolverTest extends TestCase
18+
{
19+
/**
20+
* @var \Magento\Framework\ObjectManagerInterface
21+
*/
22+
protected $objectManager;
23+
24+
/**
25+
* @var FrontNameResolver
26+
*/
27+
protected $model;
28+
29+
/**
30+
* @inheritDoc
31+
*/
32+
protected function setUp(): void
33+
{
34+
$this->objectManager = Bootstrap::getObjectManager();
35+
$this->model = $this->objectManager->create(
36+
FrontNameResolver::class
37+
);
38+
$_SERVER['HTTP_HOST'] = 'localhost';
39+
}
40+
41+
/**
42+
* @magentoDbIsolation enabled
43+
* @magentoConfigFixture current_store web/unsecure/base_url http://example.com/
44+
*/
45+
public function testIsHostBackend()
46+
{
47+
$this->assertTrue($this->model->isHostBackend());
48+
}
49+
}

0 commit comments

Comments
 (0)