Skip to content

Commit

Permalink
ENGCOM-4458: [Forwardport] Resolve incorrect scope code selection whe…
Browse files Browse the repository at this point in the history
…n the requested scopeCode is null #21633
  • Loading branch information
sivaschenko authored Apr 28, 2019
2 parents 49ad674 + 6a03666 commit d8a3eaa
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions lib/internal/Magento/Framework/App/Config/ScopeCodeResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/
namespace Magento\Framework\App\Config;

use Magento\Framework\App\ScopeInterface;
use Magento\Framework\App\ScopeResolverPool;

/**
Expand Down Expand Up @@ -34,28 +35,32 @@ public function __construct(ScopeResolverPool $scopeResolverPool)
* Resolve scope code
*
* @param string $scopeType
* @param string $scopeCode
* @param string|null $scopeCode
* @return string
*/
public function resolve($scopeType, $scopeCode)
{
if (isset($this->resolvedScopeCodes[$scopeType][$scopeCode])) {
return $this->resolvedScopeCodes[$scopeType][$scopeCode];
}
if (($scopeCode === null || is_numeric($scopeCode))
&& $scopeType !== ScopeConfigInterface::SCOPE_TYPE_DEFAULT
) {

if ($scopeType !== ScopeConfigInterface::SCOPE_TYPE_DEFAULT) {
$scopeResolver = $this->scopeResolverPool->get($scopeType);
$resolverScopeCode = $scopeResolver->getScope($scopeCode);
} else {
$resolverScopeCode = $scopeCode;
}

if ($resolverScopeCode instanceof \Magento\Framework\App\ScopeInterface) {
if ($resolverScopeCode instanceof ScopeInterface) {
$resolverScopeCode = $resolverScopeCode->getCode();
}

if ($scopeCode === null) {
$scopeCode = $resolverScopeCode;
}

$this->resolvedScopeCodes[$scopeType][$scopeCode] = $resolverScopeCode;

return $resolverScopeCode;
}

Expand Down

0 comments on commit d8a3eaa

Please sign in to comment.