Skip to content

Commit 3a06d40

Browse files
author
Sergii Kovalenko
committed
MAGETWO-60890: Fatal error logging in as admin user with restricted role
1 parent 839e086 commit 3a06d40

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

app/code/Magento/Store/Model/Config/Processor/Fallback.php

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
namespace Magento\Store\Model\Config\Processor;
77

88
use Magento\Framework\App\Config\Spi\PostProcessorInterface;
9+
use Magento\Framework\App\DeploymentConfig;
910
use Magento\Framework\App\ResourceConnection;
1011
use Magento\Store\Api\Data\StoreInterface;
1112
use Magento\Store\Api\Data\WebsiteInterface;
@@ -42,15 +43,22 @@ class Fallback implements PostProcessorInterface
4243
* @var array
4344
*/
4445
private $websiteData = [];
46+
4547
/**
4648
* @var Store
4749
*/
4850
private $storeResource;
51+
4952
/**
5053
* @var Website
5154
*/
5255
private $websiteResource;
5356

57+
/**
58+
* @var DeploymentConfig
59+
*/
60+
private $deploymentConfig;
61+
5462
/**
5563
* Fallback constructor.
5664
* @param Scopes $scopes
@@ -59,21 +67,28 @@ public function __construct(
5967
Scopes $scopes,
6068
ResourceConnection $resourceConnection,
6169
Store $storeResource,
62-
Website $websiteResource
70+
Website $websiteResource,
71+
DeploymentConfig $deploymentConfig
6372
) {
6473
$this->scopes = $scopes;
6574
$this->resourceConnection = $resourceConnection;
6675
$this->storeResource = $storeResource;
6776
$this->websiteResource = $websiteResource;
77+
$this->deploymentConfig = $deploymentConfig;
6878
}
6979

7080
/**
7181
* @inheritdoc
7282
*/
7383
public function process(array $data)
7484
{
75-
$this->storeData = $this->storeResource->readAllStores();
76-
$this->websiteData = $this->websiteResource->readAllWebsites();
85+
if ($this->deploymentConfig->isDbAvailable()) {//read only from db
86+
$this->storeData = $this->storeResource->readAllStores();
87+
$this->websiteData = $this->websiteResource->readAllWebsites();
88+
} else {
89+
$this->storeData = $this->scopes->get('stores');
90+
$this->websiteData = $this->scopes->get('websites');
91+
}
7792

7893
$defaultConfig = isset($data['default']) ? $data['default'] : [];
7994
$result = [

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,6 @@ public function __construct(Reader $reader, $configType, $fileKey)
4848
public function get($path = '')
4949
{
5050
$data = new DataObject($this->reader->load($this->fileKey));
51-
if ($path !== '' && $path !== null) {
52-
$path = '/' . $path;
53-
}
54-
return $data->getData($this->configType . $path) ?: [];
51+
return $data->getData($this->configType) ?: [];
5552
}
5653
}

0 commit comments

Comments
 (0)