Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Forwardport] Resolve incorrect scope code selection when the requested scopeCode is null #21633

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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