Skip to content

Commit d8a3eaa

Browse files
authored
ENGCOM-4458: [Forwardport] Resolve incorrect scope code selection when the requested scopeCode is null #21633
2 parents 49ad674 + 6a03666 commit d8a3eaa

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

lib/internal/Magento/Framework/App/Config/ScopeCodeResolver.php

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66
namespace Magento\Framework\App\Config;
77

8+
use Magento\Framework\App\ScopeInterface;
89
use Magento\Framework\App\ScopeResolverPool;
910

1011
/**
@@ -34,28 +35,32 @@ public function __construct(ScopeResolverPool $scopeResolverPool)
3435
* Resolve scope code
3536
*
3637
* @param string $scopeType
37-
* @param string $scopeCode
38+
* @param string|null $scopeCode
3839
* @return string
3940
*/
4041
public function resolve($scopeType, $scopeCode)
4142
{
4243
if (isset($this->resolvedScopeCodes[$scopeType][$scopeCode])) {
4344
return $this->resolvedScopeCodes[$scopeType][$scopeCode];
4445
}
45-
if (($scopeCode === null || is_numeric($scopeCode))
46-
&& $scopeType !== ScopeConfigInterface::SCOPE_TYPE_DEFAULT
47-
) {
46+
47+
if ($scopeType !== ScopeConfigInterface::SCOPE_TYPE_DEFAULT) {
4848
$scopeResolver = $this->scopeResolverPool->get($scopeType);
4949
$resolverScopeCode = $scopeResolver->getScope($scopeCode);
5050
} else {
5151
$resolverScopeCode = $scopeCode;
5252
}
5353

54-
if ($resolverScopeCode instanceof \Magento\Framework\App\ScopeInterface) {
54+
if ($resolverScopeCode instanceof ScopeInterface) {
5555
$resolverScopeCode = $resolverScopeCode->getCode();
5656
}
5757

58+
if ($scopeCode === null) {
59+
$scopeCode = $resolverScopeCode;
60+
}
61+
5862
$this->resolvedScopeCodes[$scopeType][$scopeCode] = $resolverScopeCode;
63+
5964
return $resolverScopeCode;
6065
}
6166

0 commit comments

Comments
 (0)