| @@ -4,8 +4,9 @@ | ||
| 4 | 4 | namespace JFB_Modules\Cli\Commands; |
| 5 | 5 | |
| 6 | 6 | use Jet_Form_Builder\Db_Queries\Execution_Builder; |
| 7 | 7 | use Jet_Form_Builder\Migrations\Migration_Exception; |
| 8 | +use Jet_Form_Builder\Migrations\Migration_Incomplete_Exception; | |
| 8 | 9 | use Jet_Form_Builder\Migrations\Migrator; |
| 9 | 10 | use Jet_Form_Builder\Migrations\Profilers\Cli_Migration_Profiler; |
| 10 | 11 | |
| 11 | 12 | // If this file is called directly, abort. |
| @@ -30,8 +31,22 @@ | ||
| 30 | 31 | Execution_Builder::instance()->transaction_commit(); |
| 31 | 32 | |
| 32 | 33 | \WP_CLI::line(); |
| 33 | 34 | \WP_CLI::success( 'Migrated successfully' ); |
| 35 | + | |
| 36 | + } catch ( Migration_Incomplete_Exception $exception ) { | |
| 37 | + // Not a data-loss failure: a time-boxed migration (e.g. the SSR registry | |
| 38 | + // import) already committed its own partial progress and a resume cursor | |
| 39 | + // before throwing this — see its own docblock. There is nothing left to roll | |
| 40 | + // back here; running the command again resumes from that cursor. It is, | |
| 41 | + // however, not "done" either — `WP_CLI::success()` here would exit 0, which | |
| 42 | + // automation polling this command's exit code would read as "migration | |
| 43 | + // complete" and never retry, silently leaving the site on partially-migrated | |
| 44 | + // data (review finding, issues-tracker #20361 follow-up). `WP_CLI::error()` | |
| 45 | + // gives it the same non-zero exit code as a genuine failure so such automation | |
| 46 | + // reliably re-invokes the command instead. | |
| 47 | + \WP_CLI::line(); | |
| 48 | + \WP_CLI::error( 'Migration is still in progress. Run this command again to continue.' ); | |
| 34 | 49 | |
| 35 | 50 | } catch ( Migration_Exception $exception ) { |
| 36 | 51 | Execution_Builder::instance()->transaction_rollback(); |
| 37 | 52 | \WP_CLI::error( $exception->getMessage() ); |