| @@ -37,8 +37,11 @@ | ||
| 37 | 37 | ], |
| 38 | 38 | '1.2.3' => [ // @since 1.2.3 |
| 39 | 39 | 'add_url_query_string_column_to_contact_segmentation', |
| 40 | 40 | ], |
| 41 | + '1.2.7' => [ // @since 1.5.0 | |
| 42 | + 'add_funnel_contact_table', | |
| 43 | + ], | |
| 41 | 44 | ]; |
| 42 | 45 | |
| 43 | 46 | /** |
| 44 | 47 | * Install constructor. |
| @@ -73,10 +76,16 @@ | ||
| 73 | 76 | public function maybe_update() { |
| 74 | 77 | $current_db_version = $this->get_current_database_version(); |
| 75 | 78 | $current_db_version = ! empty( $current_db_version ) ? $current_db_version : 0; |
| 76 | 79 | self::$updater = new Db_Updater(); |
| 77 | - $has_new_update = false; | |
| 78 | 80 | |
| 81 | + // Avoid stacking duplicate batches (e.g. admin refreshes) or colliding with an in-flight run. | |
| 82 | + if ( self::$updater->has_pending_migrations() ) { | |
| 83 | + return; | |
| 84 | + } | |
| 85 | + | |
| 86 | + $has_new_update = false; | |
| 87 | + | |
| 79 | 88 | foreach ( self::$updates as $version => $update_callbacks ) { |
| 80 | 89 | if ( version_compare( $current_db_version, $version, '<' ) ) { |
| 81 | 90 | foreach ( $update_callbacks as $update_callback ) { |
| 82 | 91 | self::$updater->push_to_queue( [ |
| @@ -89,8 +98,9 @@ | ||
| 89 | 98 | } |
| 90 | 99 | } |
| 91 | 100 | |
| 92 | 101 | if ( $has_new_update ) { |
| 102 | + self::$updater->gate_multisite_initial_loopback = true; | |
| 93 | 103 | self::$updater->save()->dispatch(); |
| 94 | 104 | } |
| 95 | 105 | } |
| 96 | 106 | |
| @@ -122,9 +132,9 @@ | ||
| 122 | 132 | $sellkit_prefix = Database::DATABASE_PREFIX; |
| 123 | 133 | |
| 124 | 134 | // phpcs:disable |
| 125 | 135 | $installed_tables = $wpdb->get_results( |
| 126 | - "SHOW TABLES from {$database_name} | |
| 136 | + "SHOW TABLES from `{$database_name}` | |
| 127 | 137 | where Tables_in_{$database_name} like '%applied_funnel%' |
| 128 | 138 | or Tables_in_{$database_name} like '%contact_segmentation%' |
| 129 | 139 | " ); |
| 130 | 140 | // phpcs:enable |