Skip to content

Commit

Permalink
MAGETWO-60890: Fatal error logging in as admin user with restricted role
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergii Kovalenko committed Dec 1, 2016
1 parent 839e086 commit 3a06d40
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
21 changes: 18 additions & 3 deletions app/code/Magento/Store/Model/Config/Processor/Fallback.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
namespace Magento\Store\Model\Config\Processor;

use Magento\Framework\App\Config\Spi\PostProcessorInterface;
use Magento\Framework\App\DeploymentConfig;
use Magento\Framework\App\ResourceConnection;
use Magento\Store\Api\Data\StoreInterface;
use Magento\Store\Api\Data\WebsiteInterface;
Expand Down Expand Up @@ -42,15 +43,22 @@ class Fallback implements PostProcessorInterface
* @var array
*/
private $websiteData = [];

/**
* @var Store
*/
private $storeResource;

/**
* @var Website
*/
private $websiteResource;

/**
* @var DeploymentConfig
*/
private $deploymentConfig;

/**
* Fallback constructor.
* @param Scopes $scopes
Expand All @@ -59,21 +67,28 @@ public function __construct(
Scopes $scopes,
ResourceConnection $resourceConnection,
Store $storeResource,
Website $websiteResource
Website $websiteResource,
DeploymentConfig $deploymentConfig
) {
$this->scopes = $scopes;
$this->resourceConnection = $resourceConnection;
$this->storeResource = $storeResource;
$this->websiteResource = $websiteResource;
$this->deploymentConfig = $deploymentConfig;
}

/**
* @inheritdoc
*/
public function process(array $data)
{
$this->storeData = $this->storeResource->readAllStores();
$this->websiteData = $this->websiteResource->readAllWebsites();
if ($this->deploymentConfig->isDbAvailable()) {//read only from db
$this->storeData = $this->storeResource->readAllStores();
$this->websiteData = $this->websiteResource->readAllWebsites();
} else {
$this->storeData = $this->scopes->get('stores');
$this->websiteData = $this->scopes->get('websites');
}

$defaultConfig = isset($data['default']) ? $data['default'] : [];
$result = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,6 @@ public function __construct(Reader $reader, $configType, $fileKey)
public function get($path = '')
{
$data = new DataObject($this->reader->load($this->fileKey));
if ($path !== '' && $path !== null) {
$path = '/' . $path;
}
return $data->getData($this->configType . $path) ?: [];
return $data->getData($this->configType) ?: [];
}
}

0 comments on commit 3a06d40

Please sign in to comment.