Skip to content

Commit 11724e6

Browse files
committed
B2B-1785: Cannot enable remote storage with install command when modules are not enabled
1 parent 3c5ff49 commit 11724e6

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,13 @@ public function createConfig(array $options, DeploymentConfig $deploymentConfig)
141141
*/
142142
public function validate(array $options, DeploymentConfig $deploymentConfig): array
143143
{
144+
// deployment configuration existence determines readiness of object manager to resolve remote storage drivers
145+
$isDeploymentConfigExists = (bool) $deploymentConfig->getConfigData();
146+
147+
if (!$isDeploymentConfigExists) {
148+
return [];
149+
}
150+
144151
$driver = $options[self::OPTION_REMOTE_STORAGE_DRIVER] ?? DriverPool::FILE;
145152

146153
if ($driver === DriverPool::FILE) {

setup/src/Magento/Setup/Model/Installer.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
use Magento\Setup\Module\SetupFactory;
5656
use Magento\Setup\Validator\DbValidator;
5757
use Magento\Store\Model\Store;
58+
use Magento\RemoteStorage\Setup\ConfigOptionsList as FileStorageValidator;
5859

5960
/**
6061
* Class Installer contains the logic to install Magento application.
@@ -356,6 +357,7 @@ public function install($request)
356357
}
357358
$script[] = ['Installing database schema:', 'installSchema', [$request]];
358359
$script[] = ['Installing search configuration...', 'installSearchConfiguration', [$request]];
360+
$script[] = ['Validating file storage configuration...', 'validateFileStorageConfiguration', [$request]];
359361
$script[] = ['Installing user configuration...', 'installUserConfig', [$request]];
360362
$script[] = ['Enabling caches:', 'updateCaches', [true]];
361363
$script[] = ['Installing data...', 'installDataFixtures', [$request]];
@@ -1197,6 +1199,25 @@ public function installSearchConfiguration($data)
11971199
$searchConfig->saveConfiguration($data);
11981200
}
11991201

1202+
/**
1203+
* Validate file storage on install. Since it is a deployment-based configuration, the config is already present,
1204+
* but this function confirms it can connect (in the case of Remote Storage) after Object Manager
1205+
* has all necessary dependencies loaded to do so.
1206+
*
1207+
* @param array $data
1208+
* @throws ValidationException
1209+
* @throws Exception
1210+
*/
1211+
public function validateFileStorageConfiguration(array $data)
1212+
{
1213+
$fileStorageValidator = $this->objectManagerProvider->get()->get(FileStorageValidator::class);
1214+
$validationErrors = $fileStorageValidator->validate($data, $this->deploymentConfig);
1215+
1216+
if (!empty($validationErrors)) {
1217+
throw new ValidationException(__(implode(PHP_EOL, $validationErrors)));
1218+
}
1219+
}
1220+
12001221
/**
12011222
* Create data handler
12021223
*

0 commit comments

Comments
 (0)