Skip to content

Commit 393946a

Browse files
committed
MAGETWO-52187: Magento re-install with minimum admin access breaks installation
- Backward Compatible Changes
1 parent ca4223f commit 393946a

File tree

2 files changed

+24
-8
lines changed

2 files changed

+24
-8
lines changed

setup/src/Magento/Setup/Controller/Install.php

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
use Zend\View\Model\ViewModel;
2121
use Magento\Setup\Console\Command\InstallCommand;
2222
use Magento\SampleData;
23-
use Magento\Framework\App\DeploymentConfig;
2423

2524
/**
2625
* Install controller
@@ -61,20 +60,17 @@ class Install extends AbstractActionController
6160
* @param InstallerFactory $installerFactory
6261
* @param ProgressFactory $progressFactory
6362
* @param \Magento\Framework\Setup\SampleData\State $sampleDataState
64-
* @param \Magento\Framework\App\DeploymentConfig $deploymentConfig
6563
*/
6664
public function __construct(
6765
WebLogger $logger,
6866
InstallerFactory $installerFactory,
6967
ProgressFactory $progressFactory,
70-
\Magento\Framework\Setup\SampleData\State $sampleDataState,
71-
DeploymentConfig $deploymentConfig
68+
\Magento\Framework\Setup\SampleData\State $sampleDataState
7269
) {
7370
$this->log = $logger;
7471
$this->installer = $installerFactory->create($logger);
7572
$this->progressFactory = $progressFactory;
7673
$this->sampleDataState = $sampleDataState;
77-
$this->deploymentConfig = $deploymentConfig;
7874
}
7975

8076
/**
@@ -164,7 +160,7 @@ public function progressAction()
164160
*/
165161
private function checkForPriorInstall()
166162
{
167-
if ($this->deploymentConfig->isAvailable()) {
163+
if ($this->getDeploymentConfig()->isAvailable()) {
168164
throw new \Magento\Setup\Exception('Magento application is already installed.');
169165
}
170166
}
@@ -266,4 +262,20 @@ private function importAdminUserForm()
266262
$result[AdminAccount::KEY_LAST_NAME] = $result[AdminAccount::KEY_USER];
267263
return $result;
268264
}
265+
266+
/**
267+
* Get Deployment Config
268+
*
269+
* @return \Magento\Framework\App\DeploymentConfig
270+
*
271+
* @deprecated
272+
*/
273+
private function getDeploymentConfig()
274+
{
275+
if ($this->deploymentConfig === null) {
276+
$this->deploymentConfig = \Magento\Framework\App\ObjectManager::getInstance()
277+
->get(\Magento\Framework\App\DeploymentConfig::class);
278+
}
279+
return $this->deploymentConfig;
280+
}
269281
}

setup/src/Magento/Setup/Test/Unit/Controller/InstallTest.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,13 @@ public function setUp()
5555
$this->webLogger,
5656
$installerFactory,
5757
$this->progressFactory,
58-
$this->sampleDataState,
59-
$this->deploymentConfig
58+
$this->sampleDataState
6059
);
60+
61+
$deploymentConfigReflection = new \ReflectionClass(get_class($this->controller));
62+
$deploymentConfigReflectionProperty = $deploymentConfigReflection->getProperty('deploymentConfig');
63+
$deploymentConfigReflectionProperty->setAccessible(true);
64+
$deploymentConfigReflectionProperty->setValue($this->controller, $this->deploymentConfig);
6165
}
6266

6367
public function testIndexAction()

0 commit comments

Comments
 (0)