| @@ -176,11 +176,11 @@ | ||
| 176 | 176 | |
| 177 | 177 | /** |
| 178 | 178 | * Method get_wp_options_join(). |
| 179 | 179 | * |
| 180 | - * @param array $fields Extra option fields. | |
| 181 | - * @param string $view_query view query. | |
| 182 | - * @param array<string, mixed> $params Additional parameters. | |
| 180 | + * @param array $fields Extra option fields. | |
| 181 | + * @param string $view_query view query. | |
| 182 | + * @param array<string, mixed> $params Additional parameters. | |
| 183 | 183 | |
| 184 | 184 | * |
| 185 | 185 | * NOTE: This method is used to improve the performance of wp_options view, as the old view with subquery for each field will cause performance issue when there are many sites, and this method will generate the SQL with LEFT JOIN which will be much faster than subquery. |
| 186 | 186 | * The alias of wp table must be 'wp' to make sure the LEFT JOIN works, and the alias of wp_options table will be 'owp' + key of field in fields array, and the join condition is owp.wpid = wp.id AND owp.name = field name, and the select field is owp.value AS field name. |
| @@ -3316,8 +3316,26 @@ | ||
| 3316 | 3316 | 'groupid' => $groupid, |
| 3317 | 3317 | ) |
| 3318 | 3318 | ); |
| 3319 | 3319 | } |
| 3320 | + | |
| 3321 | + // Add primary monitor, use global settings. | |
| 3322 | + $success = MainWP_DB_Uptime_Monitoring::instance()->update_wp_monitor( | |
| 3323 | + array( | |
| 3324 | + 'wpid' => $websiteid, | |
| 3325 | + 'suburl' => '', | |
| 3326 | + ) | |
| 3327 | + ); | |
| 3328 | + | |
| 3329 | + $opt_name = 'mainwp_primary_monitor_repair_attempts_for_wp_' . $websiteid; | |
| 3330 | + | |
| 3331 | + if ( ! $success ) { | |
| 3332 | + update_option( $opt_name, 1 ); | |
| 3333 | + MainWP_Utility::unhide_mainwp_message( 'failed-attempt-create-primary-monitor-' . $websiteid ); | |
| 3334 | + } elseif ( get_option( $opt_name ) ) { | |
| 3335 | + delete_option( $opt_name ); | |
| 3336 | + } | |
| 3337 | + | |
| 3320 | 3338 | MainWP_Manage_Sites_List_Table::invalidate_manage_sites_cache(); |
| 3321 | 3339 | return $websiteid; |
| 3322 | 3340 | } |
| 3323 | 3341 | } |
| @@ -3340,9 +3358,9 @@ | ||
| 3340 | 3358 | $this->wpdb->delete( $this->table_name( 'wp_group' ), array( 'wpid' => $websiteid ) ); |
| 3341 | 3359 | $this->wpdb->delete( $this->table_name( 'wp_sync' ), array( 'wpid' => $websiteid ) ); |
| 3342 | 3360 | $this->wpdb->delete( $this->table_name( 'wp_options' ), array( 'wpid' => $websiteid ) ); |
| 3343 | 3361 | MainWP_Encrypt_Data_Lib::remove_key_file( $websiteid ); |
| 3344 | - MainWP_DB_Uptime_Monitoring::instance()->delete_monitor( array( 'wpid' => $websiteid ) ); | |
| 3362 | + MainWP_DB_Uptime_Monitoring::instance()->delete_site_monitors( $websiteid ); | |
| 3345 | 3363 | MainWP_Manage_Sites_List_Table::invalidate_manage_sites_cache(); |
| 3346 | 3364 | return $nr; |
| 3347 | 3365 | } |
| 3348 | 3366 | |