@@ -391,8 +391,12 @@ public function install($request)
391
391
foreach ($ script as $ item ) {
392
392
list ($ message , $ method , $ params ) = $ item ;
393
393
$ this ->log ->log ($ message );
394
- // phpcs:ignore Magento2.Functions.DiscouragedFunction
395
- call_user_func_array ([$ this , $ method ], $ params );
394
+ try {
395
+ $ this ->$ method (...$ params );
396
+ } catch (RuntimeException $ e ) {
397
+ $ this ->revertRemoteStorageConfiguration ();
398
+ throw $ e ;
399
+ }
396
400
$ this ->logProgress ();
397
401
}
398
402
$ this ->log ->logSuccess ('Magento installation complete. ' );
@@ -1218,6 +1222,7 @@ public function validateRemoteStorageConfiguration(array $data)
1218
1222
$ validationErrors = $ remoteStorageValidator ->validate ($ data , $ this ->deploymentConfig );
1219
1223
1220
1224
if (!empty ($ validationErrors )) {
1225
+ $ this ->revertRemoteStorageConfiguration ();
1221
1226
throw new ValidationException (__ (implode (PHP_EOL , $ validationErrors )));
1222
1227
}
1223
1228
}
@@ -1787,4 +1792,19 @@ private function getDisabledCacheTypes(array $cacheTypesToCheck): array
1787
1792
1788
1793
return $ disabledCaches ;
1789
1794
}
1795
+
1796
+ /**
1797
+ * Revert remote storage configuration back to local file driver
1798
+ */
1799
+ private function revertRemoteStorageConfiguration ()
1800
+ {
1801
+ if (!$ this ->deploymentConfigWriter ->checkIfWritable ()) {
1802
+ return ;
1803
+ }
1804
+
1805
+ $ remoteStorageData = new ConfigData (ConfigFilePool::APP_ENV );
1806
+ $ remoteStorageData ->set ('remote_storage ' , ['driver ' => 'file ' ]);
1807
+ $ configData = [$ remoteStorageData ->getFileKey () => $ remoteStorageData ->getData ()];
1808
+ $ this ->deploymentConfigWriter ->saveConfig ($ configData , true );
1809
+ }
1790
1810
}
0 commit comments