PluginProbe
JetFormBuilder — Dynamic Blocks Form Builder / 3.6.5.3
JetFormBuilder — Dynamic Blocks Form Builder v3.6.5.3
3.6.5.3 3.6.5.2 3.6.5.1 3.6.5 3.6.4.2 3.6.4.1 3.6.4 3.6.3.1 3.6.3 3.6.2.2 3.6.2.1 3.6.2 3.6.1.1 3.6.1 3.6.0.1 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 All 131 releases
jetformbuilder / modules / cli / commands / upgrade-database.php

upgrade-database.php in JetFormBuilder — Dynamic Blocks Form Builder 3.6.5.3, at modules/cli/commands/upgrade-database.php

56 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3
4 namespace JFB_Modules\Cli\Commands;
5
6 use Jet_Form_Builder\Db_Queries\Execution_Builder;
7 use Jet_Form_Builder\Migrations\Migration_Exception;
8 use Jet_Form_Builder\Migrations\Migration_Incomplete_Exception;
9 use Jet_Form_Builder\Migrations\Migrator;
10 use Jet_Form_Builder\Migrations\Profilers\Cli_Migration_Profiler;
11
12 // If this file is called directly, abort.
13 if ( ! defined( 'WPINC' ) ) {
14 die;
15 }
16
17 class Upgrade_Database implements Base_Command_It {
18
19 public function rep_item_id() {
20 return 'db-upgrade';
21 }
22
23 public function condition(): bool {
24 return true;
25 }
26
27 public function do_command( $args, $assoc_args ) {
28 try {
29 Execution_Builder::instance()->transaction_start();
30 Migrator::instance()->install( new Cli_Migration_Profiler() );
31 Execution_Builder::instance()->transaction_commit();
32
33 \WP_CLI::line();
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.' );
49
50 } catch ( Migration_Exception $exception ) {
51 Execution_Builder::instance()->transaction_rollback();
52 \WP_CLI::error( $exception->getMessage() );
53 }
54 }
55 }
56