← All changes
|
modules/rest-api/endpoints/install-migrations-endpoint.php
+14
-1
3.6.3
→
3.6.6
View file →
| @@ -4,8 +4,9 @@ | ||
| 4 | 4 | namespace JFB_Modules\Rest_Api\Endpoints; |
| 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 JFB_Components\Rest_Api\Rest_Api_Endpoint_Base; |
| 10 | 11 | |
| 11 | 12 | // If this file is called directly, abort. |
| @@ -45,8 +46,19 @@ | ||
| 45 | 46 | Migrator::instance()->install(); |
| 46 | 47 | |
| 47 | 48 | Execution_Builder::instance()->transaction_commit(); |
| 48 | 49 | |
| 50 | + } catch ( Migration_Incomplete_Exception $exception ) { | |
| 51 | + // Not a failure: a time-boxed migration (e.g. the SSR registry import) already | |
| 52 | + // committed its own partial progress and a resume cursor before throwing this — | |
| 53 | + // see its own docblock. There is nothing left to roll back here; calling this | |
| 54 | + // endpoint again resumes from that cursor. | |
| 55 | + return new \WP_REST_Response( | |
| 56 | + array( | |
| 57 | + 'message' => __( 'Migration is still in progress. Call this endpoint again to continue.', 'jet-form-builder' ), | |
| 58 | + 'complete' => false, | |
| 59 | + ) | |
| 60 | + ); | |
| 49 | 61 | } catch ( Migration_Exception $exception ) { |
| 50 | 62 | Execution_Builder::instance()->transaction_rollback(); |
| 51 | 63 | |
| 52 | 64 | return new \WP_REST_Response( |
| @@ -59,9 +71,10 @@ | ||
| 59 | 71 | } |
| 60 | 72 | |
| 61 | 73 | return new \WP_REST_Response( |
| 62 | 74 | array( |
| 63 | - 'message' => __( 'Successfully installed migrations.', 'jet-form-builder' ), | |
| 75 | + 'message' => __( 'Successfully installed migrations.', 'jet-form-builder' ), | |
| 76 | + 'complete' => true, | |
| 64 | 77 | ) |
| 65 | 78 | ); |
| 66 | 79 | } |
| 67 | 80 | } |