| @@ -41,23 +41,21 @@ | ||
| 41 | 41 | $this->status_recipient = Notification::USER_SUBSCRIBED; |
| 42 | 42 | |
| 43 | 43 | return array( |
| 44 | 44 | 'security_tweaks' => $this->update_security_tweaks( $old_data['security_tweaks'] ), |
| 45 | - 'scan' => empty( $old_data['scan'] ) ? array() : $this->update_scan( $old_data['scan'] ), | |
| 46 | - 'iplockout' => empty( $old_data['iplockout'] ) | |
| 45 | + 'scan' => ! isset( $old_data['scan'] ) || ! is_array( $old_data['scan'] ) ? array() : $this->update_scan( $old_data['scan'] ), | |
| 46 | + 'iplockout' => ! isset( $old_data['iplockout'] ) || ! is_array( $old_data['iplockout'] ) | |
| 47 | 47 | ? array() |
| 48 | 48 | : $this->update_ip_lockout( $old_data['iplockout'] ), |
| 49 | - // Empty data if Audit module is disabled. | |
| 50 | - 'audit' => empty( $old_data['audit'] ) ? array() : $this->update_audit( $old_data['audit'] ), | |
| 51 | - 'two_factor' => empty( $old_data['two_factor'] ) | |
| 49 | + 'two_factor' => ! isset( $old_data['two_factor'] ) || ! is_array( $old_data['two_factor'] ) | |
| 52 | 50 | ? array() |
| 53 | 51 | : $this->update_two_factor( $old_data['two_factor'] ), |
| 54 | 52 | // Checks for empty values Mask Login and Security Headers inside methods. |
| 55 | 53 | 'mask_login' => $this->update_mask_login( $old_data['mask_login'] ), |
| 56 | 54 | 'security_headers' => $this->update_security_headers( $old_data['security_headers'] ), |
| 57 | - 'settings' => empty( $old_data['settings'] ) ? array() : $old_data['settings'], | |
| 58 | - 'blocklist_monitor' => empty( $old_data['blocklist_monitor'] ) ? array() : $old_data['blocklist_monitor'], | |
| 59 | - 'pwned_passwords' => empty( $old_data['pwned_passwords'] ) ? array() : $old_data['pwned_passwords'], | |
| 55 | + 'settings' => ! isset( $old_data['settings'] ) || ! is_array( $old_data['settings'] ) ? array() : $old_data['settings'], | |
| 56 | + 'blocklist_monitor' => ! isset( $old_data['blocklist_monitor'] ) || ! is_array( $old_data['blocklist_monitor'] ) ? array() : $old_data['blocklist_monitor'], | |
| 57 | + 'pwned_passwords' => ! isset( $old_data['pwned_passwords'] ) || ! is_array( $old_data['pwned_passwords'] ) ? array() : $old_data['pwned_passwords'], | |
| 60 | 58 | ); |
| 61 | 59 | } |
| 62 | 60 | |
| 63 | 61 | /** |
| @@ -115,9 +113,9 @@ | ||
| 115 | 113 | if ( |
| 116 | 114 | ( ( is_numeric( $frequency_type ) && 30 === (int) $frequency_type ) ) |
| 117 | 115 | || 'monthly' === $frequency_type |
| 118 | 116 | ) { |
| 119 | - if ( empty( $report_day ) ) { | |
| 117 | + if ( '' === $report_day ) { | |
| 120 | 118 | return $days; |
| 121 | 119 | } |
| 122 | 120 | if ( is_numeric( $report_day ) ) { |
| 123 | 121 | $days['day_n'] = $report_day; |
| @@ -144,9 +142,9 @@ | ||
| 144 | 142 | * @return array |
| 145 | 143 | */ |
| 146 | 144 | private function get_subscribers( array $data ): array { |
| 147 | 145 | $subscribers = array(); |
| 148 | - if ( ! empty( $data ) ) { | |
| 146 | + if ( is_array( $data ) && array() !== $data ) { | |
| 149 | 147 | foreach ( $data as $receipt ) { |
| 150 | 148 | $subscribers['out_house_recipients'][] = array( |
| 151 | 149 | 'name' => $receipt['first_name'], |
| 152 | 150 | 'email' => $receipt['email'], |
| @@ -178,9 +176,9 @@ | ||
| 178 | 176 | 'notification' => isset( $old_tweaks['notification'] ) |
| 179 | 177 | ? ( $old_tweaks['notification'] ? 'enabled' : 'disabled' ) |
| 180 | 178 | : 'disabled', |
| 181 | 179 | // Prepare from 'notification_repeat' to configs['reminder'] with default value 'weekly'. |
| 182 | - 'notification_repeat' => empty( $old_tweaks['notification_repeat'] ) | |
| 180 | + 'notification_repeat' => ! isset( $old_tweaks['notification_repeat'] ) || '' === $old_tweaks['notification_repeat'] | |
| 183 | 181 | ? 'weekly' |
| 184 | 182 | : ( $old_tweaks['notification_repeat'] ? 'daily' : 'weekly' ), |
| 185 | 183 | 'data' => $old_tweaks['data'] ?? array(), |
| 186 | 184 | ); |
| @@ -203,19 +201,19 @@ | ||
| 203 | 201 | * @return array |
| 204 | 202 | */ |
| 205 | 203 | public function update_scan( array $old_data ): array { |
| 206 | 204 | $scan = array( |
| 207 | - 'integrity_check' => empty( $old_data['scan_core'] ) ? true : $old_data['scan_core'], | |
| 208 | - 'check_core' => empty( $old_data['check_core'] ) ? true : $old_data['check_core'], | |
| 209 | - 'check_plugins' => empty( $old_data['check_plugins'] ) ? false : $old_data['check_plugins'], | |
| 210 | - 'check_known_vuln' => empty( $old_data['scan_vuln'] ) ? true : $old_data['scan_vuln'], | |
| 211 | - 'scan_malware' => empty( $old_data['scan_content'] ) ? false : $old_data['scan_content'], | |
| 212 | - 'filesize' => empty( $old_data['max_filesize'] ) ? 3 : $old_data['max_filesize'], | |
| 205 | + 'integrity_check' => ! isset( $old_data['scan_core'] ) || ! is_bool( $old_data['scan_core'] ) ? true : $old_data['scan_core'], | |
| 206 | + 'check_core' => ! isset( $old_data['check_core'] ) || ! is_bool( $old_data['check_core'] ) ? true : $old_data['check_core'], | |
| 207 | + 'check_plugins' => ! isset( $old_data['check_plugins'] ) || ! is_bool( $old_data['check_plugins'] ) ? false : $old_data['check_plugins'], | |
| 208 | + 'check_known_vuln' => ! isset( $old_data['scan_vuln'] ) || ! is_bool( $old_data['scan_vuln'] ) ? true : $old_data['scan_vuln'], | |
| 209 | + 'scan_malware' => ! isset( $old_data['scan_content'] ) || ! is_bool( $old_data['scan_content'] ) ? false : $old_data['scan_content'], | |
| 210 | + 'filesize' => ! isset( $old_data['max_filesize'] ) || ! is_int( $old_data['max_filesize'] ) ? 3 : $old_data['max_filesize'], | |
| 213 | 211 | // Should get bool value. |
| 214 | 212 | 'report' => isset( $old_data['report'] ) && $old_data['report'] ? 'enabled' : 'disabled', |
| 215 | - 'always_send' => empty( $old_data['always_send'] ) ? false : $old_data['always_send'], | |
| 216 | - 'time' => empty( $old_data['time'] ) ? '4:00' : $old_data['time'], | |
| 217 | - 'frequency' => empty( $old_data['frequency'] ) | |
| 213 | + 'always_send' => ! isset( $old_data['always_send'] ) || ! is_bool( $old_data['always_send'] ) ? false : $old_data['always_send'], | |
| 214 | + 'time' => ! isset( $old_data['time'] ) || ! is_string( $old_data['time'] ) || '' === $old_data['time'] ? '4:00' : $old_data['time'], | |
| 215 | + 'frequency' => ! isset( $old_data['frequency'] ) || ! is_string( $old_data['frequency'] ) || '' === $old_data['frequency'] | |
| 218 | 216 | ? 'weekly' |
| 219 | 217 | : $this->frequency_type( $old_data['frequency'] ), |
| 220 | 218 | // Should get bool value. |
| 221 | 219 | 'notification' => isset( $old_data['notification'] ) && $old_data['notification'] |
| @@ -220,12 +218,12 @@ | ||
| 220 | 218 | // Should get bool value. |
| 221 | 219 | 'notification' => isset( $old_data['notification'] ) && $old_data['notification'] |
| 222 | 220 | ? 'enabled' |
| 223 | 221 | : 'disabled', |
| 224 | - 'always_send_notification' => empty( $old_data['always_send_notification'] ) | |
| 222 | + 'always_send_notification' => ! isset( $old_data['always_send_notification'] ) || ! is_bool( $old_data['always_send_notification'] ) | |
| 225 | 223 | ? false |
| 226 | 224 | : $old_data['always_send_notification'], |
| 227 | - 'error_send' => empty( $old_data['error_send'] ) ? false : $old_data['error_send'], | |
| 225 | + 'error_send' => ! isset( $old_data['error_send'] ) || ! is_bool( $old_data['error_send'] ) ? false : $old_data['error_send'], | |
| 228 | 226 | 'email_subject_issue_found' => $old_data['email_subject_issue'] ?? '', |
| 229 | 227 | 'email_subject_issue_not_found' => $old_data['email_subject'] ?? '', |
| 230 | 228 | 'email_subject_error' => $old_data['email_subject_error'] ?? '', |
| 231 | 229 | 'email_content_issue_found' => $old_data['email_has_issue'] ?? '', |
| @@ -230,20 +228,20 @@ | ||
| 230 | 228 | 'email_subject_error' => $old_data['email_subject_error'] ?? '', |
| 231 | 229 | 'email_content_issue_found' => $old_data['email_has_issue'] ?? '', |
| 232 | 230 | 'email_content_issue_not_found' => $old_data['email_all_ok'] ?? '', |
| 233 | 231 | 'email_content_error' => $old_data['email_content_error'] ?? '', |
| 234 | - // since 2.7.0. | |
| 235 | - 'scheduled_scanning' => false, | |
| 232 | + // Since 5.9.0. | |
| 233 | + 'check_abandoned_plugin' => true, | |
| 236 | 234 | ); |
| 237 | 235 | |
| 238 | - $scan['report_subscribers'] = empty( $old_data['recipients'] ) | |
| 236 | + $scan['report_subscribers'] = ! isset( $old_data['recipients'] ) || ! is_array( $old_data['recipients'] ) || array() === $old_data['recipients'] | |
| 239 | 237 | ? array() |
| 240 | 238 | : $this->get_subscribers( $old_data['recipients'] ); |
| 241 | - $scan['notification_subscribers'] = empty( $old_data['recipients_notification'] ) | |
| 239 | + $scan['notification_subscribers'] = ! isset( $old_data['recipients_notification'] ) || ! is_array( $old_data['recipients_notification'] ) || array() === $old_data['recipients_notification'] | |
| 242 | 240 | ? array() |
| 243 | 241 | : $this->get_subscribers( $old_data['recipients_notification'] ); |
| 244 | 242 | // Todo: need the key 'last_report_sent'? It's no always in the unixtime format. |
| 245 | - if ( empty( $old_data['frequency'] ) ) { | |
| 243 | + if ( ! isset( $old_data['frequency'] ) || '' === $old_data['frequency'] ) { | |
| 246 | 244 | $scan['day'] = 'sunday'; |
| 247 | 245 | $scan['day_n'] = 1; |
| 248 | 246 | |
| 249 | 247 | return $scan; |
| @@ -276,77 +274,77 @@ | ||
| 276 | 274 | $default_ip_lockout_values = ( new Model_Blacklist_Lockout() )->get_default_values(); |
| 277 | 275 | $default_ua_lockout_values = ( new Model_Ua_Lockout() )->get_default_values(); |
| 278 | 276 | |
| 279 | 277 | $iplockout = array( |
| 280 | - 'login_protection' => empty( $old_data['login_protection'] ) | |
| 278 | + 'login_protection' => ! isset( $old_data['login_protection'] ) || ! is_bool( $old_data['login_protection'] ) | |
| 281 | 279 | ? true : $old_data['login_protection'], |
| 282 | - 'login_protection_login_attempt' => empty( $old_data['login_protection_login_attempt'] ) | |
| 280 | + 'login_protection_login_attempt' => ! isset( $old_data['login_protection_login_attempt'] ) || ! is_numeric( $old_data['login_protection_login_attempt'] ) | |
| 283 | 281 | ? '5' : $old_data['login_protection_login_attempt'], |
| 284 | - 'login_protection_lockout_timeframe' => empty( $old_data['login_protection_lockout_timeframe'] ) | |
| 282 | + 'login_protection_lockout_timeframe' => ! isset( $old_data['login_protection_lockout_timeframe'] ) || ! is_numeric( $old_data['login_protection_lockout_timeframe'] ) | |
| 285 | 283 | ? '300' : $old_data['login_protection_lockout_timeframe'], |
| 286 | - 'login_protection_lockout_ban' => empty( $old_data['login_protection_lockout_ban'] ) | |
| 284 | + 'login_protection_lockout_ban' => ! isset( $old_data['login_protection_lockout_ban'] ) || ! is_bool( $old_data['login_protection_lockout_ban'] ) | |
| 287 | 285 | ? false : $old_data['login_protection_lockout_ban'], |
| 288 | - 'login_protection_lockout_duration' => empty( $old_data['login_protection_lockout_duration'] ) | |
| 286 | + 'login_protection_lockout_duration' => ! isset( $old_data['login_protection_lockout_duration'] ) || ! is_numeric( $old_data['login_protection_lockout_duration'] ) | |
| 289 | 287 | ? '4' : $old_data['login_protection_lockout_duration'], |
| 290 | - 'login_protection_lockout_duration_unit' => empty( $old_data['login_protection_lockout_duration_unit'] ) | |
| 288 | + 'login_protection_lockout_duration_unit' => ! isset( $old_data['login_protection_lockout_duration_unit'] ) || ! is_string( $old_data['login_protection_lockout_duration_unit'] ) | |
| 291 | 289 | ? 'hours' : $old_data['login_protection_lockout_duration_unit'], |
| 292 | - 'login_protection_lockout_message' => empty( $old_data['login_protection_lockout_message'] ) | |
| 290 | + 'login_protection_lockout_message' => ! isset( $old_data['login_protection_lockout_message'] ) || '' === $old_data['login_protection_lockout_message'] | |
| 293 | 291 | ? $default_login_lockout_values['message'] |
| 294 | 292 | : $old_data['login_protection_lockout_message'], |
| 295 | - 'username_blacklist' => empty( $old_data['username_blacklist'] ) | |
| 293 | + 'username_blacklist' => ! isset( $old_data['username_blacklist'] ) || ! is_string( $old_data['username_blacklist'] ) | |
| 296 | 294 | ? '' : $old_data['username_blacklist'], |
| 297 | - 'detect_404' => empty( $old_data['detect_404'] ) | |
| 295 | + 'detect_404' => ! isset( $old_data['detect_404'] ) || ! is_bool( $old_data['detect_404'] ) | |
| 298 | 296 | ? true : $old_data['detect_404'], |
| 299 | - 'detect_404_threshold' => empty( $old_data['detect_404_threshold'] ) | |
| 297 | + 'detect_404_threshold' => ! isset( $old_data['detect_404_threshold'] ) || ! is_numeric( $old_data['detect_404_threshold'] ) | |
| 300 | 298 | ? '20' : $old_data['detect_404_threshold'], |
| 301 | - 'detect_404_timeframe' => empty( $old_data['detect_404_timeframe'] ) | |
| 299 | + 'detect_404_timeframe' => ! isset( $old_data['detect_404_timeframe'] ) || ! is_numeric( $old_data['detect_404_timeframe'] ) | |
| 302 | 300 | ? '300' : $old_data['detect_404_timeframe'], |
| 303 | - 'detect_404_lockout_ban' => empty( $old_data['detect_404_lockout_ban'] ) | |
| 301 | + 'detect_404_lockout_ban' => ! isset( $old_data['detect_404_lockout_ban'] ) || ! is_bool( $old_data['detect_404_lockout_ban'] ) | |
| 304 | 302 | ? false : $old_data['detect_404_lockout_ban'], |
| 305 | - 'detect_404_lockout_duration' => empty( $old_data['detect_404_lockout_duration'] ) | |
| 303 | + 'detect_404_lockout_duration' => ! isset( $old_data['detect_404_lockout_duration'] ) || ! is_numeric( $old_data['detect_404_lockout_duration'] ) | |
| 306 | 304 | ? '4' : $old_data['detect_404_lockout_duration'], |
| 307 | - 'detect_404_lockout_duration_unit' => empty( $old_data['detect_404_lockout_duration_unit'] ) | |
| 305 | + 'detect_404_lockout_duration_unit' => ! isset( $old_data['detect_404_lockout_duration_unit'] ) || ! is_string( $old_data['detect_404_lockout_duration_unit'] ) | |
| 308 | 306 | ? 'hours' : $old_data['detect_404_lockout_duration_unit'], |
| 309 | - 'detect_404_lockout_message' => empty( $old_data['detect_404_lockout_message'] ) | |
| 307 | + 'detect_404_lockout_message' => ! isset( $old_data['detect_404_lockout_message'] ) || '' === $old_data['detect_404_lockout_message'] | |
| 310 | 308 | ? $default_404_lockout_values['message'] |
| 311 | 309 | : $old_data['detect_404_lockout_message'], |
| 312 | 310 | 'detect_404_blacklist' => $merged_bl_file_data, |
| 313 | 311 | 'detect_404_whitelist' => $merged_wl_file_data, |
| 314 | - 'detect_404_logged' => empty( $old_data['detect_404_logged'] ) | |
| 312 | + 'detect_404_logged' => ! isset( $old_data['detect_404_logged'] ) || ! is_bool( $old_data['detect_404_logged'] ) | |
| 315 | 313 | ? true : $old_data['detect_404_logged'], |
| 316 | - 'ip_blacklist' => empty( $old_data['ip_blacklist'] ) | |
| 314 | + 'ip_blacklist' => ! isset( $old_data['ip_blacklist'] ) || ! is_string( $old_data['ip_blacklist'] ) | |
| 317 | 315 | ? '' : $old_data['ip_blacklist'], |
| 318 | - 'ip_whitelist' => empty( $old_data['ip_whitelist'] ) | |
| 316 | + 'ip_whitelist' => ! isset( $old_data['ip_whitelist'] ) || ! is_string( $old_data['ip_whitelist'] ) | |
| 319 | 317 | ? '' : $old_data['ip_whitelist'], |
| 320 | - 'country_blacklist' => empty( $old_data['country_blacklist'] ) | |
| 318 | + 'country_blacklist' => ! isset( $old_data['country_blacklist'] ) || ! is_string( $old_data['country_blacklist'] ) | |
| 321 | 319 | ? '' : $old_data['country_blacklist'], |
| 322 | - 'country_whitelist' => empty( $old_data['country_whitelist'] ) | |
| 320 | + 'country_whitelist' => ! isset( $old_data['country_whitelist'] ) || ! is_string( $old_data['country_whitelist'] ) | |
| 323 | 321 | ? '' : $old_data['country_whitelist'], |
| 324 | - 'ip_lockout_message' => empty( $old_data['ip_lockout_message'] ) | |
| 322 | + 'ip_lockout_message' => ! isset( $old_data['ip_lockout_message'] ) || '' === $old_data['ip_lockout_message'] | |
| 325 | 323 | ? $default_ip_lockout_values['message'] |
| 326 | 324 | : $old_data['ip_lockout_message'], |
| 327 | - 'login_lockout_notification' => empty( $old_data['login_lockout_notification'] ) | |
| 325 | + 'login_lockout_notification' => ! isset( $old_data['login_lockout_notification'] ) || ! is_bool( $old_data['login_lockout_notification'] ) | |
| 328 | 326 | ? true : $old_data['login_lockout_notification'], |
| 329 | - 'ip_lockout_notification' => empty( $old_data['ip_lockout_notification'] ) | |
| 327 | + 'ip_lockout_notification' => ! isset( $old_data['ip_lockout_notification'] ) || ! is_bool( $old_data['ip_lockout_notification'] ) | |
| 330 | 328 | ? true : $old_data['ip_lockout_notification'], |
| 331 | 329 | 'notification' => 'enabled', |
| 332 | - 'cooldown_enabled' => empty( $old_data['cooldown_enabled'] ) | |
| 330 | + 'cooldown_enabled' => ! isset( $old_data['cooldown_enabled'] ) || ! is_bool( $old_data['cooldown_enabled'] ) | |
| 333 | 331 | ? false : $old_data['cooldown_enabled'], |
| 334 | - 'cooldown_number_lockout' => empty( $old_data['cooldown_number_lockout'] ) | |
| 332 | + 'cooldown_number_lockout' => ! isset( $old_data['cooldown_number_lockout'] ) || ! is_numeric( $old_data['cooldown_number_lockout'] ) | |
| 335 | 333 | ? '3' : $old_data['cooldown_number_lockout'], |
| 336 | - 'cooldown_period' => empty( $old_data['cooldown_period'] ) | |
| 334 | + 'cooldown_period' => ! isset( $old_data['cooldown_period'] ) || ! is_numeric( $old_data['cooldown_period'] ) | |
| 337 | 335 | ? '24' : $old_data['cooldown_period'], |
| 338 | 336 | 'report' => isset( $old_data['report'] ) && $old_data['report'] ? 'enabled' : 'disabled', |
| 339 | - 'report_frequency' => empty( $old_data['report_frequency'] ) | |
| 337 | + 'report_frequency' => ! isset( $old_data['report_frequency'] ) || '' === $old_data['report_frequency'] | |
| 340 | 338 | ? 'weekly' |
| 341 | 339 | : $this->frequency_type( $old_data['report_frequency'] ), |
| 342 | 340 | // Data for 'day' below. |
| 343 | - 'report_time' => empty( $old_data['report_time'] ) | |
| 341 | + 'report_time' => ! isset( $old_data['report_time'] ) || '' === $old_data['report_time'] | |
| 344 | 342 | ? '4:00' : $old_data['report_time'], |
| 345 | - 'storage_days' => empty( $old_data['storage_days'] ) | |
| 343 | + 'storage_days' => ! isset( $old_data['storage_days'] ) || '' === $old_data['storage_days'] | |
| 346 | 344 | ? '180' : $old_data['storage_days'], |
| 347 | 345 | 'geoIP_db' => $old_data['geoIP_db'] ?? '', |
| 348 | - 'ip_blocklist_cleanup_interval' => empty( $old_data['ip_blocklist_cleanup_interval'] ) | |
| 346 | + 'ip_blocklist_cleanup_interval' => ! isset( $old_data['ip_blocklist_cleanup_interval'] ) || '' === $old_data['ip_blocklist_cleanup_interval'] | |
| 349 | 347 | ? 'never' : $old_data['ip_blocklist_cleanup_interval'], |
| 350 | 348 | // For UA Banning. |
| 351 | 349 | 'ua_banning_enabled' => $old_data['ua_banning_enabled'] ?? false, |
| 352 | 350 | 'ua_banning_message' => $old_data['ua_banning_message'] ?? $default_ua_lockout_values['message'], |
| @@ -357,20 +355,20 @@ | ||
| 357 | 355 | // Global IP list. |
| 358 | 356 | 'global_ip_list' => $old_data['global_ip_list'] ?? false, |
| 359 | 357 | 'global_ip_list_blocklist_autosync' => $old_data['global_ip_list_blocklist_autosync'] ?? false, |
| 360 | 358 | ); |
| 361 | - if ( isset( $old_data['lastReportSent'] ) && ! empty( $old_data['lastReportSent'] ) ) { | |
| 359 | + if ( isset( $old_data['lastReportSent'] ) && '' !== $old_data['lastReportSent'] ) { | |
| 362 | 360 | $iplockout['last_sent'] = $old_data['lastReportSent']; |
| 363 | 361 | } |
| 364 | 362 | |
| 365 | - $iplockout['report_subscribers'] = empty( $old_data['report_receipts'] ) | |
| 363 | + $iplockout['report_subscribers'] = ! isset( $old_data['report_receipts'] ) || ! is_array( $old_data['report_receipts'] ) || array() === $old_data['report_receipts'] | |
| 366 | 364 | ? array() |
| 367 | 365 | : $this->get_subscribers( $old_data['report_receipts'] ); |
| 368 | - $iplockout['notification_subscribers'] = empty( $old_data['receipts'] ) | |
| 366 | + $iplockout['notification_subscribers'] = ! isset( $old_data['receipts'] ) || ! is_array( $old_data['receipts'] ) || array() === $old_data['receipts'] | |
| 369 | 367 | ? array() |
| 370 | 368 | : $this->get_subscribers( $old_data['receipts'] ); |
| 371 | 369 | |
| 372 | - if ( empty( $old_data['report_frequency'] ) ) { | |
| 370 | + if ( ! isset( $old_data['report_frequency'] ) || '' === $old_data['report_frequency'] ) { | |
| 373 | 371 | $iplockout['day'] = 'sunday'; |
| 374 | 372 | $iplockout['day_n'] = 1; |
| 375 | 373 | |
| 376 | 374 | return $iplockout; |
| @@ -394,27 +392,27 @@ | ||
| 394 | 392 | 'enabled' => is_bool( $old_data['enabled'] ) |
| 395 | 393 | ? $old_data['enabled'] |
| 396 | 394 | : (bool) $old_data['enabled'], |
| 397 | 395 | 'report' => isset( $old_data['notification'] ) && $old_data['notification'] ? 'enabled' : 'disabled', |
| 398 | - 'frequency' => empty( $old_data['frequency'] ) | |
| 396 | + 'frequency' => ! isset( $old_data['frequency'] ) || '' === $old_data['frequency'] | |
| 399 | 397 | ? 'weekly' |
| 400 | 398 | : $this->frequency_type( $old_data['frequency'] ), |
| 401 | - 'time' => empty( $old_data['time'] ) | |
| 399 | + 'time' => ! isset( $old_data['time'] ) || '' === $old_data['time'] | |
| 402 | 400 | ? '4:00' |
| 403 | 401 | : $old_data['time'], |
| 404 | - 'storage_days' => empty( $old_data['storage_days'] ) | |
| 402 | + 'storage_days' => ! isset( $old_data['storage_days'] ) || '' === $old_data['storage_days'] | |
| 405 | 403 | ? '6 months' |
| 406 | 404 | : $old_data['storage_days'], |
| 407 | 405 | ); |
| 408 | - if ( isset( $old_data['lastReportSent'] ) && ! empty( $old_data['lastReportSent'] ) ) { | |
| 406 | + if ( isset( $old_data['lastReportSent'] ) && '' !== $old_data['lastReportSent'] ) { | |
| 409 | 407 | $audit['last_sent'] = $old_data['lastReportSent']; |
| 410 | 408 | } |
| 411 | 409 | |
| 412 | - $audit['subscribers'] = empty( $old_data['receipts'] ) | |
| 410 | + $audit['subscribers'] = ! isset( $old_data['receipts'] ) || ! is_array( $old_data['receipts'] ) || array() === $old_data['receipts'] | |
| 413 | 411 | ? array() |
| 414 | 412 | : $this->get_subscribers( $old_data['receipts'] ); |
| 415 | 413 | |
| 416 | - if ( empty( $old_data['frequency'] ) ) { | |
| 414 | + if ( ! isset( $old_data['frequency'] ) || '' === $old_data['frequency'] ) { | |
| 417 | 415 | $audit['day'] = 'sunday'; |
| 418 | 416 | $audit['day_n'] = 1; |
| 419 | 417 | |
| 420 | 418 | return $audit; |
| @@ -430,17 +428,20 @@ | ||
| 430 | 428 | * |
| 431 | 429 | * @return array |
| 432 | 430 | */ |
| 433 | 431 | public function update_two_factor( array $old_data ): array { |
| 432 | + $user_roles = $old_data['user_roles'] ?? array(); | |
| 433 | + $force_auth_roles = $old_data['force_auth_roles'] ?? array(); | |
| 434 | + $force_auth_roles = array_values( array_intersect( $force_auth_roles, $user_roles ) ); | |
| 434 | 435 | |
| 435 | 436 | return array( |
| 436 | - 'enabled' => $old_data['enabled'], | |
| 437 | - 'lost_phone' => $old_data['lost_phone'], | |
| 438 | - 'force_auth' => $old_data['force_auth'], | |
| 439 | - 'force_auth_mess' => $old_data['force_auth_mess'], | |
| 440 | - 'user_roles' => $old_data['user_roles'], | |
| 441 | - 'force_auth_roles' => $old_data['force_auth_roles'], | |
| 442 | - 'custom_graphic' => $old_data['custom_graphic'], | |
| 437 | + 'enabled' => $old_data['enabled'] ?? false, | |
| 438 | + 'lost_phone' => $old_data['lost_phone'] ?? true, | |
| 439 | + 'force_auth' => $old_data['force_auth'] ?? false, | |
| 440 | + 'force_auth_mess' => $old_data['force_auth_mess'] ?? '', | |
| 441 | + 'user_roles' => $user_roles, | |
| 442 | + 'force_auth_roles' => $force_auth_roles, | |
| 443 | + 'custom_graphic' => $old_data['custom_graphic'] ?? false, | |
| 443 | 444 | 'custom_graphic_type' => $old_data['custom_graphic_type'] ?? Two_Fa::CUSTOM_GRAPHIC_TYPE_UPLOAD, |
| 444 | 445 | 'custom_graphic_url' => $old_data['custom_graphic_url'] ?? '', |
| 445 | 446 | 'custom_graphic_link' => $old_data['custom_graphic_link'] ?? '', |
| 446 | 447 | 'email_subject' => $old_data['email_subject'] ?? '', |
| @@ -445,9 +446,10 @@ | ||
| 445 | 446 | 'custom_graphic_link' => $old_data['custom_graphic_link'] ?? '', |
| 446 | 447 | 'email_subject' => $old_data['email_subject'] ?? '', |
| 447 | 448 | 'email_sender' => $old_data['email_sender'] ?? '', |
| 448 | 449 | 'email_body' => $old_data['email_body'] ?? '', |
| 449 | - 'app_title' => '', | |
| 450 | + 'app_title' => $old_data['app_title'] ?? '', | |
| 451 | + 'detect_woo' => $old_data['detect_woo'] ?? false, | |
| 450 | 452 | ); |
| 451 | 453 | } |
| 452 | 454 | |
| 453 | 455 | /** |
| @@ -457,9 +459,9 @@ | ||
| 457 | 459 | * |
| 458 | 460 | * @return array |
| 459 | 461 | */ |
| 460 | 462 | public function update_mask_login( array $old_data ): array { |
| 461 | - if ( empty( $old_data ) ) { | |
| 463 | + if ( array() === $old_data ) { | |
| 462 | 464 | // Sometimes migrated data is empty. |
| 463 | 465 | return array( |
| 464 | 466 | 'mask_url' => '', |
| 465 | 467 | 'redirect_traffic' => 'off', |
| @@ -467,9 +469,8 @@ | ||
| 467 | 469 | 'enabled' => false, |
| 468 | 470 | 'redirect_traffic_page_id' => 0, |
| 469 | 471 | ); |
| 470 | 472 | } else { |
| 471 | - | |
| 472 | 473 | return array( |
| 473 | 474 | 'enabled' => $old_data['enabled'], |
| 474 | 475 | 'mask_url' => $old_data['mask_url'] ?? '', |
| 475 | 476 | 'redirect_traffic' => $old_data['redirect_traffic'] ? 'custom_url' : 'off', |
| @@ -488,9 +489,9 @@ | ||
| 488 | 489 | * @since 2.5.0 Remove 'ALLOW-FROM' directive and move to 'sameorigin' by default. |
| 489 | 490 | * Leave 'sh_xframe_urls' for config migration. |
| 490 | 491 | */ |
| 491 | 492 | public function update_security_headers( array $old_data ): array { |
| 492 | - if ( empty( $old_data ) ) { | |
| 493 | + if ( array() === $old_data ) { | |
| 493 | 494 | // Sometimes migrated data is empty. |
| 494 | 495 | $model_sec_headers = new Security_Headers(); |
| 495 | 496 | |
| 496 | 497 | return array( |