-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
Refactor ConfigGenerator to replace/set crypt key instead of append #11155
Changes from 3 commits
13daa74
f50ad05
4f3e981
2718be3
b517623
345a7f3
ae06955
43e9751
4b748cf
010097d
2316cd8
c7ca261
eb33d60
61d9767
aec956f
e440946
885ecf8
91ee875
3faf8b5
1fd5b0e
a2ae382
c868fa2
d78ae56
b2146db
bab5e31
c638fd7
62eff1d
58aab5e
e8fe7ed
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
namespace Magento\Framework\Config\Data; | ||
|
||
/** | ||
* Factory for ConfigData | ||
* @api | ||
*/ | ||
class ConfigDataFactory | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry I missed this before but this factory should either be updated to match the standard defined in http://devdocs.magento.com/guides/v2.2/extension-dev-guide/factories.html or actually it might be possible to use the autogenerated factory here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Autogenerated factories are not allowed in |
||
{ | ||
/** | ||
* Returns a new instance of ConfigData on every call. | ||
* | ||
* @param string $fileKey | ||
* @return ConfigData | ||
*/ | ||
public function create(string $fileKey) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can update this to use PHP 7's return type declaration if you would like. http://php.net/manual/en/migration70.new-features.php#migration70.new-features.return-type-declarations |
||
{ | ||
return new ConfigData($fileKey); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,13 +6,14 @@ | |
|
||
namespace Magento\Setup\Model; | ||
|
||
use Magento\Framework\App\ObjectManager; | ||
use Magento\Framework\Config\Data\ConfigData; | ||
use Magento\Framework\Config\Data\ConfigDataFactory; | ||
use Magento\Framework\Config\File\ConfigFilePool; | ||
use Magento\Framework\Math\Random; | ||
use Magento\Framework\App\DeploymentConfig; | ||
use Magento\Framework\Config\ConfigOptionsListConstants; | ||
use Magento\Framework\App\State; | ||
use Magento\Framework\App\ObjectManagerFactory; | ||
|
||
/** | ||
* Creates deployment config data based on user input array | ||
|
@@ -49,16 +50,26 @@ class ConfigGenerator | |
*/ | ||
protected $deploymentConfig; | ||
|
||
/** | ||
* @var ConfigDataFactory | ||
*/ | ||
private $configDataFactory; | ||
|
||
/** | ||
* Constructor | ||
* | ||
* @param Random $random | ||
* @param DeploymentConfig $deploymentConfig | ||
* @param ConfigDataFactory $configDataFactory | ||
*/ | ||
public function __construct(Random $random, DeploymentConfig $deploymentConfig) | ||
{ | ||
public function __construct( | ||
Random $random, | ||
DeploymentConfig $deploymentConfig, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As mentioned we need to keep the |
||
ConfigDataFactory $configDataFactory | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
) { | ||
$this->random = $random; | ||
$this->deploymentConfig = $deploymentConfig; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unfortunately we still need to assign There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Aah, I thought I added id back. |
||
$this->configDataFactory = $configDataFactory; | ||
} | ||
|
||
/** | ||
|
@@ -70,15 +81,12 @@ public function createCryptConfig(array $data) | |
{ | ||
$currentKey = $this->deploymentConfig->get(ConfigOptionsListConstants::CONFIG_PATH_CRYPT_KEY); | ||
|
||
$configData = new ConfigData(ConfigFilePool::APP_ENV); | ||
$configData = $this->configDataFactory->create(ConfigFilePool::APP_ENV); | ||
if (isset($data[ConfigOptionsListConstants::INPUT_KEY_ENCRYPTION_KEY])) { | ||
if ($currentKey !== null) { | ||
$key = $currentKey . "\n" . $data[ConfigOptionsListConstants::INPUT_KEY_ENCRYPTION_KEY]; | ||
} else { | ||
$key = $data[ConfigOptionsListConstants::INPUT_KEY_ENCRYPTION_KEY]; | ||
} | ||
|
||
$configData->set(ConfigOptionsListConstants::CONFIG_PATH_CRYPT_KEY, $key); | ||
$configData->set( | ||
ConfigOptionsListConstants::CONFIG_PATH_CRYPT_KEY, | ||
$data[ConfigOptionsListConstants::INPUT_KEY_ENCRYPTION_KEY] | ||
); | ||
} else { | ||
if ($currentKey === null) { | ||
$configData->set( | ||
|
@@ -99,7 +107,7 @@ public function createCryptConfig(array $data) | |
*/ | ||
public function createSessionConfig(array $data) | ||
{ | ||
$configData = new ConfigData(ConfigFilePool::APP_ENV); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nice work, good to see this being moved out to a factory. |
||
$configData = $this->configDataFactory->create(ConfigFilePool::APP_ENV); | ||
|
||
if (isset($data[ConfigOptionsListConstants::INPUT_KEY_SESSION_SAVE])) { | ||
$configData->set( | ||
|
@@ -132,7 +140,7 @@ public function createDefinitionsConfig(array $data) | |
*/ | ||
public function createDbConfig(array $data) | ||
{ | ||
$configData = new ConfigData(ConfigFilePool::APP_ENV); | ||
$configData = $this->configDataFactory->create(ConfigFilePool::APP_ENV); | ||
|
||
$optional = [ | ||
ConfigOptionsListConstants::INPUT_KEY_DB_HOST, | ||
|
@@ -182,7 +190,7 @@ public function createDbConfig(array $data) | |
*/ | ||
public function createResourceConfig() | ||
{ | ||
$configData = new ConfigData(ConfigFilePool::APP_ENV); | ||
$configData = $this->configDataFactory->create(ConfigFilePool::APP_ENV); | ||
|
||
if ($this->deploymentConfig->get(ConfigOptionsListConstants::CONFIG_PATH_RESOURCE_DEFAULT_SETUP) === null) { | ||
$configData->set(ConfigOptionsListConstants::CONFIG_PATH_RESOURCE_DEFAULT_SETUP, 'default'); | ||
|
@@ -198,7 +206,7 @@ public function createResourceConfig() | |
*/ | ||
public function createXFrameConfig() | ||
{ | ||
$configData = new ConfigData(ConfigFilePool::APP_ENV); | ||
$configData = $this->configDataFactory->create(ConfigFilePool::APP_ENV); | ||
if ($this->deploymentConfig->get(ConfigOptionsListConstants::CONFIG_PATH_X_FRAME_OPT) === null) { | ||
$configData->set(ConfigOptionsListConstants::CONFIG_PATH_X_FRAME_OPT, 'SAMEORIGIN'); | ||
} | ||
|
@@ -212,7 +220,7 @@ public function createXFrameConfig() | |
*/ | ||
public function createModeConfig() | ||
{ | ||
$configData = new ConfigData(ConfigFilePool::APP_ENV); | ||
$configData = $this->configDataFactory->create(ConfigFilePool::APP_ENV); | ||
if ($this->deploymentConfig->get(State::PARAM_MODE) === null) { | ||
$configData->set(State::PARAM_MODE, State::MODE_DEFAULT); | ||
} | ||
|
@@ -227,7 +235,7 @@ public function createModeConfig() | |
*/ | ||
public function createCacheHostsConfig(array $data) | ||
{ | ||
$configData = new ConfigData(ConfigFilePool::APP_ENV); | ||
$configData = $this->configDataFactory->create(ConfigFilePool::APP_ENV); | ||
if (isset($data[ConfigOptionsListConstants::INPUT_KEY_CACHE_HOSTS])) { | ||
$hostData = explode(',', $data[ConfigOptionsListConstants::INPUT_KEY_CACHE_HOSTS]); | ||
$hosts = []; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So since it is a patch release we cannot add these tag currently. @renttek Can you check all the classes and remove the
@api
tag if you added it in.