From 3a25428920d08e887a49fd64aa40966d62777e6c Mon Sep 17 00:00:00 2001 From: Tu Van Date: Thu, 8 Oct 2026 15:16:15 +0700 Subject: [PATCH] [Magento] Swap env.php atomically in magento:cleanup_cache_prefix The task removed the live shared env.php before moving env_tmp.php into place. A request landing in that gap finds no install date, so Magento redirects it to the setup wizard. A single mv -f is one rename(2), so the live release always sees an env.php. The release-side rm is dropped too: {{bin/symlink}} is ln -nfs and replaces the old link. --- recipe/magento2.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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); });