Skip to content

Commit 2df76ce

Browse files
Magento failure subtasks should fail gracefully in case of new or blank installs.
1 parent 9354d97 commit 2df76ce

1 file changed

Lines changed: 20 additions & 8 deletions

File tree

recipe/magento2.php

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -133,16 +133,24 @@
133133
});
134134

135135
set('config_import_needed_on_current', function () {
136-
// detect if app:config:import is needed on the current (live) release
137-
// do not use {{bin/magento}} as it resolves via release_or_current_path which is unreliable in failure scenarios
136+
137+
if (!test('[ -d {{current_path}}/{{magento_dir}} ] && [ -f {{current_path}}/{{magento_dir}}/bin/magento ]')) {
138+
writeln('Current Magento installation is unavailable => import skipped');
139+
return false;
140+
}
141+
138142
try {
143+
// detect if app:config:import is needed on the current (live) release
144+
// do not use {{bin/magento}} as it resolves via release_or_current_path which is unreliable in failure scenarios
139145
run('{{bin/php}} {{current_path}}/{{magento_dir}}/bin/magento app:config:status');
140146
} catch (RunException $e) {
141147
if ($e->getExitCode() == CONFIG_IMPORT_NEEDED_EXIT_CODE) {
142148
return true;
143149
}
144150

145-
throw $e;
151+
// In failure scenarios, non-status errors should not break deploy:failed handlers.
152+
writeln('Unable to determine app config status on current release => import skipped');
153+
return false;
146154
}
147155
return false;
148156
});
@@ -338,11 +346,15 @@ function magentoDeployAssetsSplit(string $area)
338346

339347
desc('Config Import on current release');
340348
task('magento:config:import:on-current', function () {
341-
if (get('config_import_needed_on_current')) {
342-
// do not use {{bin/magento}} as it must run on the current (last successful) release in failure scenarios
343-
run('{{bin/php}} {{current_path}}/{{magento_dir}}/bin/magento app:config:import --no-interaction');
344-
} else {
345-
writeln('App config is up to date => import skipped');
349+
try {
350+
if (get('config_import_needed_on_current')) {
351+
// do not use {{bin/magento}} as it must run on the current (last successful) release in failure scenarios
352+
run('{{bin/php}} {{current_path}}/{{magento_dir}}/bin/magento app:config:import --no-interaction');
353+
} else {
354+
writeln('App config is up to date => import skipped');
355+
}
356+
} catch (RunException $e) {
357+
writeln('Unable to import app config on current release => import skipped');
346358
}
347359
});
348360

0 commit comments

Comments
 (0)