Skip to content

Commit 8a4cfa4

Browse files
committed
Don't check default locale if Magento is not installed, fix NumberFormatter initialization when no currency is set
1 parent 068eedf commit 8a4cfa4

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

lib/internal/Magento/Framework/Locale/Format.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public function getPriceFormat($localeCode = null, $currencyCode = null)
100100
}
101101

102102
$formatter = new \NumberFormatter(
103-
$localeCode . '@currency=' . $currency->getCode(),
103+
$currency->getCode() ? $localeCode . '@currency=' . $currency->getCode() : $localeCode,
104104
\NumberFormatter::CURRENCY
105105
);
106106
$format = $formatter->getPattern();

lib/internal/Magento/Framework/Locale/Resolver.php

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
namespace Magento\Framework\Locale;
77

88
use Magento\Framework\App\Config\ScopeConfigInterface;
9+
use Magento\Framework\App\DeploymentConfig;
10+
use Magento\Framework\App\ObjectManager;
911

1012
class Resolver implements ResolverInterface
1113
{
@@ -47,21 +49,29 @@ class Resolver implements ResolverInterface
4749
*/
4850
protected $emulatedLocales = [];
4951

52+
/**
53+
* @var DeploymentConfig
54+
*/
55+
private $deploymentConfig;
56+
5057
/**
5158
* @param ScopeConfigInterface $scopeConfig
5259
* @param string $defaultLocalePath
5360
* @param string $scopeType
5461
* @param mixed $locale
62+
* @param DeploymentConfig|null $deploymentConfig
5563
*/
5664
public function __construct(
5765
ScopeConfigInterface $scopeConfig,
5866
$defaultLocalePath,
5967
$scopeType,
60-
$locale = null
68+
$locale = null,
69+
DeploymentConfig $deploymentConfig = null
6170
) {
6271
$this->scopeConfig = $scopeConfig;
6372
$this->defaultLocalePath = $defaultLocalePath;
6473
$this->scopeType = $scopeType;
74+
$this->deploymentConfig = $deploymentConfig ?: ObjectManager::getInstance()->create(DeploymentConfig::class);
6575
$this->setLocale($locale);
6676
}
6777

@@ -88,7 +98,10 @@ public function setDefaultLocale($locale)
8898
public function getDefaultLocale()
8999
{
90100
if (!$this->defaultLocale) {
91-
$locale = $this->scopeConfig->getValue($this->getDefaultLocalePath(), $this->scopeType);
101+
$locale = false;
102+
if ($this->deploymentConfig->isAvailable() && $this->deploymentConfig->isDbAvailable()) {
103+
$locale = $this->scopeConfig->getValue($this->getDefaultLocalePath(), $this->scopeType);
104+
}
92105
if (!$locale) {
93106
$locale = self::DEFAULT_LOCALE;
94107
}

0 commit comments

Comments
 (0)