Skip to content

Commit f56e1d0

Browse files
authored
Merge pull request #7443 from magento-performance/MCP-903
[Performance] MCP-903: Fix default connection = db setting after Magento installation
2 parents 1f37c78 + 69b6483 commit f56e1d0

File tree

5 files changed

+49
-28
lines changed

5 files changed

+49
-28
lines changed

app/code/Magento/MessageQueue/Setup/ConfigOptionsList.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ public function getOptions()
6262
self::INPUT_KEY_QUEUE_DEFAULT_CONNECTION,
6363
TextConfigOption::FRONTEND_WIZARD_TEXT,
6464
self::CONFIG_PATH_QUEUE_DEFAULT_CONNECTION,
65-
'Message queues default connection. Can be db, amqp or a custom one.',
66-
self::DEFAULT_QUEUE_CONNECTION
65+
'Message queues default connection. Can be \'db\', \'amqp\' or a custom queue system.'
66+
. 'The queue system must be installed and configured, otherwise messages won\'t be processed correctly.'
6767
),
6868
];
6969
}

dev/tests/api-functional/config/post-install-setup-command-config.php.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ return [
1212
'config' => [
1313
'--remote-storage-driver' => 'aws-s3',
1414
'--remote-storage-bucket' => 'myBucket',
15-
'--remote-storage-region' => 'us-east-1'
15+
'--remote-storage-region' => 'us-east-1',
1616
]
1717
]
1818
*/

dev/tests/integration/etc/post-install-setup-command-config.php.dist

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@
66

77
// List of bin/magento setup CLI commands to run after setup:install
88
return [
9-
/*
109
[
1110
'command' => 'setup:config:set',
1211
'config' => [
12+
'--queue-default-connection' => 'db'
13+
/*
1314
'--remote-storage-driver' => 'aws-s3',
1415
'--remote-storage-bucket' => 'myBucket',
15-
'--remote-storage-region' => 'us-east-1',
16-
'--queue-default-connection' => 'db'
16+
'--remote-storage-region' => 'us-east-1'
17+
*/
1718
]
1819
]
19-
*/
2020
];

setup/src/Magento/Setup/Model/ConfigOptionsList/Lock.php

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -26,70 +26,70 @@ class Lock implements ConfigOptionsListInterface
2626
*
2727
* @const string
2828
*/
29-
const INPUT_KEY_LOCK_PROVIDER = 'lock-provider';
29+
public const INPUT_KEY_LOCK_PROVIDER = 'lock-provider';
3030

3131
/**
3232
* The name of an option to set DB prefix
3333
*
3434
* @const string
3535
*/
36-
const INPUT_KEY_LOCK_DB_PREFIX = 'lock-db-prefix';
36+
public const INPUT_KEY_LOCK_DB_PREFIX = 'lock-db-prefix';
3737

3838
/**
3939
* The name of an option to set Zookeeper host
4040
*
4141
* @const string
4242
*/
43-
const INPUT_KEY_LOCK_ZOOKEEPER_HOST = 'lock-zookeeper-host';
43+
public const INPUT_KEY_LOCK_ZOOKEEPER_HOST = 'lock-zookeeper-host';
4444

4545
/**
4646
* The name of an option to set Zookeeper path
4747
*
4848
* @const string
4949
*/
50-
const INPUT_KEY_LOCK_ZOOKEEPER_PATH = 'lock-zookeeper-path';
50+
public const INPUT_KEY_LOCK_ZOOKEEPER_PATH = 'lock-zookeeper-path';
5151

5252
/**
5353
* The name of an option to set File path
5454
*
5555
* @const string
5656
*/
57-
const INPUT_KEY_LOCK_FILE_PATH = 'lock-file-path';
57+
public const INPUT_KEY_LOCK_FILE_PATH = 'lock-file-path';
5858

5959
/**
6060
* The configuration path to save lock provider
6161
*
6262
* @const string
6363
*/
64-
const CONFIG_PATH_LOCK_PROVIDER = 'lock/provider';
64+
public const CONFIG_PATH_LOCK_PROVIDER = 'lock/provider';
6565

6666
/**
6767
* The configuration path to save DB prefix
6868
*
6969
* @const string
7070
*/
71-
const CONFIG_PATH_LOCK_DB_PREFIX = 'lock/config/prefix';
71+
public const CONFIG_PATH_LOCK_DB_PREFIX = 'lock/config/prefix';
7272

7373
/**
7474
* The configuration path to save Zookeeper host
7575
*
7676
* @const string
7777
*/
78-
const CONFIG_PATH_LOCK_ZOOKEEPER_HOST = 'lock/config/host';
78+
public const CONFIG_PATH_LOCK_ZOOKEEPER_HOST = 'lock/config/host';
7979

8080
/**
8181
* The configuration path to save Zookeeper path
8282
*
8383
* @const string
8484
*/
85-
const CONFIG_PATH_LOCK_ZOOKEEPER_PATH = 'lock/config/path';
85+
public const CONFIG_PATH_LOCK_ZOOKEEPER_PATH = 'lock/config/path';
8686

8787
/**
8888
* The configuration path to save locks directory path
8989
*
9090
* @const string
9191
*/
92-
const CONFIG_PATH_LOCK_FILE_PATH = 'lock/config/path';
92+
public const CONFIG_PATH_LOCK_FILE_PATH = 'lock/config/path';
9393

9494
/**
9595
* The list of lock providers
@@ -134,7 +134,6 @@ class Lock implements ConfigOptionsListInterface
134134
*/
135135
private $defaultConfigValues = [
136136
self::INPUT_KEY_LOCK_PROVIDER => LockBackendFactory::LOCK_DB,
137-
self::INPUT_KEY_LOCK_DB_PREFIX => null,
138137
self::INPUT_KEY_LOCK_ZOOKEEPER_PATH => ZookeeperLock::DEFAULT_PATH,
139138
];
140139

@@ -317,7 +316,10 @@ private function setDefaultConfiguration(
317316
string $lockProvider
318317
) {
319318
foreach ($this->mappingInputKeyToConfigPath[$lockProvider] as $input => $path) {
320-
$configData->set($path, $deploymentConfig->get($path, $this->getDefaultValue($input)));
319+
// do not set default value null for lock db prefix
320+
if ($input !== self::INPUT_KEY_LOCK_DB_PREFIX) {
321+
$configData->set($path, $deploymentConfig->get($path, $this->getDefaultValue($input)));
322+
}
321323
}
322324

323325
return $configData;
@@ -333,10 +335,6 @@ private function setDefaultConfiguration(
333335
*/
334336
private function getDefaultValue(string $inputKey)
335337
{
336-
if (isset($this->defaultConfigValues[$inputKey])) {
337-
return $this->defaultConfigValues[$inputKey];
338-
} else {
339-
return null;
340-
}
338+
return $this->defaultConfigValues[$inputKey] ?? null;
341339
}
342340
}

setup/src/Magento/Setup/Test/Unit/Model/ConfigOptionsList/LockTest.php

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ public function testCreateConfig(array $options, array $expectedResult)
8585

8686
/**
8787
* @return array
88+
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
8889
*/
8990
public function createConfigDataProvider(): array
9091
{
@@ -93,10 +94,7 @@ public function createConfigDataProvider(): array
9394
'options' => [],
9495
'expectedResult' => [
9596
'lock' => [
96-
'provider' => LockBackendFactory::LOCK_DB,
97-
'config' => [
98-
'prefix' => null,
99-
],
97+
'provider' => LockBackendFactory::LOCK_DB
10098
],
10199
],
102100
],
@@ -168,6 +166,31 @@ public function createConfigDataProvider(): array
168166
],
169167
],
170168
],
169+
'Check specific db lock prefix null options' => [
170+
'options' => [
171+
LockConfigOptionsList::INPUT_KEY_LOCK_PROVIDER => LockBackendFactory::LOCK_DB,
172+
LockConfigOptionsList::INPUT_KEY_LOCK_DB_PREFIX => null
173+
],
174+
'expectedResult' => [
175+
'lock' => [
176+
'provider' => LockBackendFactory::LOCK_DB
177+
],
178+
],
179+
],
180+
'Check specific db lock prefix empty options' => [
181+
'options' => [
182+
LockConfigOptionsList::INPUT_KEY_LOCK_PROVIDER => LockBackendFactory::LOCK_DB,
183+
LockConfigOptionsList::INPUT_KEY_LOCK_DB_PREFIX => ''
184+
],
185+
'expectedResult' => [
186+
'lock' => [
187+
'provider' => LockBackendFactory::LOCK_DB,
188+
'config' => [
189+
'prefix' => '',
190+
],
191+
],
192+
],
193+
],
171194
];
172195
}
173196

0 commit comments

Comments
 (0)