diff --git a/recipe/magento2.php b/recipe/magento2.php index 12d612657..df410634f 100644 --- a/recipe/magento2.php +++ b/recipe/magento2.php @@ -577,10 +577,10 @@ function magentoDeployAssetsSplit(string $area): void */ desc('Cleanup cache id_prefix env files'); task('magento:cleanup_cache_prefix', function () { - run('rm {{deploy_path}}/shared/' . ENV_CONFIG_FILE_PATH); - run('rm {{release_or_current_path}}/' . ENV_CONFIG_FILE_PATH); - run('mv {{deploy_path}}/shared/' . TMP_ENV_CONFIG_FILE_PATH . ' {{deploy_path}}/shared/' . ENV_CONFIG_FILE_PATH); - // Symlink shared dir to release dir + // A single rename(2): the live release must never see a missing env.php, or Magento answers + // "Application is not installed yet" and redirects visitors to the setup wizard. + run('mv -f {{deploy_path}}/shared/' . TMP_ENV_CONFIG_FILE_PATH . ' {{deploy_path}}/shared/' . ENV_CONFIG_FILE_PATH); + // Symlink shared dir to release dir ({{bin/symlink}} is ln -nfs, so it replaces the old link) run('{{bin/symlink}} {{deploy_path}}/shared/' . ENV_CONFIG_FILE_PATH . ' {{release_path}}/' . ENV_CONFIG_FILE_PATH); });