|
133 | 133 | }); |
134 | 134 |
|
135 | 135 | 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 | + |
138 | 142 | 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 |
139 | 145 | run('{{bin/php}} {{current_path}}/{{magento_dir}}/bin/magento app:config:status'); |
140 | 146 | } catch (RunException $e) { |
141 | 147 | if ($e->getExitCode() == CONFIG_IMPORT_NEEDED_EXIT_CODE) { |
142 | 148 | return true; |
143 | 149 | } |
144 | 150 |
|
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; |
146 | 154 | } |
147 | 155 | return false; |
148 | 156 | }); |
@@ -338,11 +346,15 @@ function magentoDeployAssetsSplit(string $area) |
338 | 346 |
|
339 | 347 | desc('Config Import on current release'); |
340 | 348 | 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'); |
346 | 358 | } |
347 | 359 | }); |
348 | 360 |
|
|
0 commit comments