PluginProbe
Defender Security – Malware Scanner, Login Security & Firewall / 6.3.0
Defender Security – Malware Scanner, Login Security & Firewall v6.3.0
6.3.0 6.2.3 6.2.4 6.2.0 6.2.1 6.2.2 6.1.0 5.3.1 5.4.0 5.4.1 5.5.0 5.5.1 5.6.0 5.6.1 5.6.2 5.7.0 5.7.1 5.7.2 5.8.0 5.8.1 5.9.0 6.0.0 6.0.1 3.0.1 3.1.0 All 141 releases
← All changes | src/class-upgrader.php +112 -6 6.1.0 → 6.3.0 View file →
@@ -347,9 +347,9 @@
347 347 }
348 348
349 349 if ( DEFENDER_DB_VERSION === $db_version ) {
350 350 // Check if we need to create pro tables (Free to Pro upgrade scenario).
351 - if ( class_exists( Bootstrap::class ) && method_exists( Bootstrap::class, 'create_database_tables' ) && ! get_site_option( 'wd_pro_tables_created' ) ) {
351 + if ( class_exists( Bootstrap::class ) && method_exists( Bootstrap::class, 'create_database_tables' ) && false === (bool) get_site_option( 'wd_pro_tables_created', false ) ) {
352 352 wd_di()->get( Bootstrap::class )->create_database_tables();
353 353 }
354 354 return;
355 355 }
@@ -483,8 +483,11 @@
483 483 }
484 484 if ( version_compare( $db_version, '6.1.0', '<' ) ) {
485 485 $this->upgrade_6_1_0();
486 486 }
487 + if ( version_compare( $db_version, '6.2.0', '<' ) ) {
488 + $this->upgrade_6_2_0();
489 + }
487 490 // This is not a new installation. Make a mark.
488 491 defender_no_fresh_install();
489 492 // Don't run any function below this line.
490 493 update_site_option( 'wd_db_version', DEFENDER_DB_VERSION );
@@ -1993,10 +1996,8 @@
1993 1996 // Add the "What's new" modal.
1994 1997 update_site_option( Feature_Modal::FEATURE_SLUG, true );
1995 1998 // Add Cloudflare challenge-platform to 404 whitelist.
1996 1999 $this->force_nf_lockout_exclusions();
1997 - // Remove the prev Breadcrumbs.
1998 - wd_di()->get( \WP_Defender\Component\Breadcrumbs::class )->delete_previous_meta();
1999 2000 }
2000 2001
2001 2002 /**
2002 2003 * Migrates the uninstall settings from v5.11 to v6.0.
@@ -2052,10 +2053,11 @@
2052 2053 $this->update_issues_report_email_template();
2053 2054 $this->fix_scheduled_scanning_left_disabled();
2054 2055 $this->migrate_tweak_reminder_schedule();
2055 2056 $this->migrate_two_fa_force_auth_roles();
2056 - // Add the "What's new" modal.
2057 - update_site_option( Feature_Modal::FEATURE_SLUG, true );
2057 + // Add the "What's new" modal only when landing on the exact release it belongs to,
2058 + // so it does not persist into later patch/minor releases (e.g. 6.0.1, 6.1).
2059 + Feature_Modal::maybe_enable_welcome_modal();
2058 2060 }
2059 2061
2060 2062 /**
2061 2063 * Upgrade to 6.1.0: Fix Tweak Reminder est_timestamp left as 0 by the 6.0.0 migration.
@@ -2074,8 +2076,112 @@
2074 2076 $this->sync_all_report_schedules();
2075 2077 }
2076 2078
2077 2079 /**
2080 + * Upgrade to 6.2.0.
2081 + *
2082 + * @return void
2083 + */
2084 + private function upgrade_6_2_0(): void {
2085 + $this->fix_notification_recipients_format();
2086 + $this->cancel_recipients_of_inactive_reports();
2087 + }
2088 +
2089 + /**
2090 + * Unsubscribe every recipient of each inactive report so their stored preferences match
2091 + * the reports' last saved on/off state.
2092 + *
2093 + * @return void
2094 + */
2095 + private function cancel_recipients_of_inactive_reports(): void {
2096 + $report_classes = array(
2097 + Tweak_Reminder::class,
2098 + Malware_Report::class,
2099 + Firewall_Report::class,
2100 + Audit_Report::class,
2101 + );
2102 +
2103 + foreach ( $report_classes as $report_class ) {
2104 + $model = wd_di()->get( $report_class );
2105 + if ( $model->check_active_status() ) {
2106 + continue;
2107 + }
2108 +
2109 + $changed = false;
2110 + foreach ( array( 'in_house_recipients', 'out_house_recipients' ) as $group ) {
2111 + $recipients = 'in_house_recipients' === $group
2112 + ? $model->in_house_recipients
2113 + : $model->out_house_recipients;
2114 + if ( ! is_array( $recipients ) ) {
2115 + continue;
2116 + }
2117 +
2118 + foreach ( $recipients as $key => $recipient ) {
2119 + if ( Notification::USER_SUBSCRIBE_CANCELED !== ( $recipient['status'] ?? '' ) ) {
2120 + $recipients[ $key ]['status'] = Notification::USER_SUBSCRIBE_CANCELED;
2121 + $changed = true;
2122 + }
2123 + }
2124 +
2125 + if ( 'in_house_recipients' === $group ) {
2126 + $model->in_house_recipients = $recipients;
2127 + } else {
2128 + $model->out_house_recipients = $recipients;
2129 + }
2130 + }
2131 +
2132 + if ( $changed ) {
2133 + $model->save();
2134 + }
2135 + }
2136 + }
2137 +
2138 + /**
2139 + * Heal recipients that older 6.x versions stored as email-keyed objects instead of arrays,
2140 + * which breaks Defender 5 on downgrade.
2141 + *
2142 + * @return void
2143 + */
2144 + private function fix_notification_recipients_format(): void {
2145 + $tables = array(
2146 + wd_di()->get( Audit_Report::class )->get_table(),
2147 + wd_di()->get( Firewall_Notification::class )->get_table(),
2148 + wd_di()->get( Firewall_Report::class )->get_table(),
2149 + wd_di()->get( Malware_Notification::class )->get_table(),
2150 + wd_di()->get( Malware_Report::class )->get_table(),
2151 + wd_di()->get( Tweak_Reminder::class )->get_table(),
2152 + );
2153 +
2154 + foreach ( $tables as $table ) {
2155 + $raw = get_site_option( $table );
2156 + if ( false === $raw ) {
2157 + continue;
2158 + }
2159 +
2160 + $data = is_array( $raw ) ? $raw : json_decode( $raw, true );
2161 + if ( ! is_array( $data ) ) {
2162 + continue;
2163 + }
2164 +
2165 + $changed = false;
2166 + foreach ( array( 'in_house_recipients', 'out_house_recipients', 'all_subscribers' ) as $key ) {
2167 + if ( isset( $data[ $key ] ) && is_array( $data[ $key ] ) ) {
2168 + // array_values() leaves a proper list untouched but reindexes an email-keyed one.
2169 + $reindexed = array_values( $data[ $key ] );
2170 + if ( $reindexed !== $data[ $key ] ) {
2171 + $data[ $key ] = $reindexed;
2172 + $changed = true;
2173 + }
2174 + }
2175 + }
2176 +
2177 + if ( $changed ) {
2178 + update_site_option( $table, wp_json_encode( $data ) );
2179 + }
2180 + }
2181 + }
2182 +
2183 + /**
2078 2184 * Sync all report schedules to match Malware Report.
2079 2185 *
2080 2186 * Since 6.0.0 the UI enforces a single shared schedule for all reports via sync_report_schedule.
2081 2187 * Sites upgrading from older versions may have each report on a different schedule.
@@ -2124,9 +2230,9 @@
2124 2230 $model->save();
2125 2231 }
2126 2232
2127 2233 // Show a one-time dashboard bubble so users know about the shared schedule.
2128 - update_site_option( 'wd_show_report_schedule_notice', true );
2234 + update_site_option( \WP_Defender\Controller\Dashboard::REPORT_SCHEDULE_NOTICE_OPTION, true );
2129 2235 }
2130 2236
2131 2237 /**
2132 2238 * Heal 'Scheduled Scanning' left disabled while its related report stayed active.