| @@ -267,9 +267,9 @@ | ||
| 267 | 267 | $est->setTime( $hour, $min, 0 ); |
| 268 | 268 | } |
| 269 | 269 | break; |
| 270 | 270 | case 'weekly': |
| 271 | - if ( empty( $this->day ) ) { | |
| 271 | + if ( '' === $this->day || null === $this->day ) { | |
| 272 | 272 | break; |
| 273 | 273 | } |
| 274 | 274 | $est->modify( 'this ' . $this->day ); |
| 275 | 275 | $est->add( $interval ); |
| @@ -446,8 +446,31 @@ | ||
| 446 | 446 | return $data; |
| 447 | 447 | } |
| 448 | 448 | |
| 449 | 449 | /** |
| 450 | + * Prepare data for persistence. | |
| 451 | + * | |
| 452 | + * Recipients are indexed by email in memory (see after_load()), so re-index them back to | |
| 453 | + * sequential arrays before storing. Otherwise they are JSON-encoded as objects, which on | |
| 454 | + * downgrade breaks Defender 5 with "all_subscribers.slice is not a function". | |
| 455 | + * | |
| 456 | + * @param array $data The data array to import values from. | |
| 457 | + * | |
| 458 | + * @return array | |
| 459 | + */ | |
| 460 | + protected function prepare_data( $data = array() ): array { | |
| 461 | + $data = parent::prepare_data( $data ); | |
| 462 | + | |
| 463 | + foreach ( array( 'in_house_recipients', 'out_house_recipients', 'all_subscribers' ) as $key ) { | |
| 464 | + if ( isset( $data[ $key ] ) && is_array( $data[ $key ] ) ) { | |
| 465 | + $data[ $key ] = array_values( $data[ $key ] ); | |
| 466 | + } | |
| 467 | + } | |
| 468 | + | |
| 469 | + return $data; | |
| 470 | + } | |
| 471 | + | |
| 472 | + /** | |
| 450 | 473 | * Overrided method to manipulate user details dynamically. |
| 451 | 474 | */ |
| 452 | 475 | protected function after_load(): void { |
| 453 | 476 | $in_house_recipients = array(); |
| @@ -482,9 +505,9 @@ | ||
| 482 | 505 | private function get_email_indexed_recipients( array $recipients ): array { |
| 483 | 506 | $email_indexed_recipients = array(); |
| 484 | 507 | |
| 485 | 508 | foreach ( $recipients as $recipient ) { |
| 486 | - if ( empty( $recipient['email'] ) ) { | |
| 509 | + if ( ! isset( $recipient['email'] ) ) { | |
| 487 | 510 | continue; |
| 488 | 511 | } |
| 489 | 512 | |
| 490 | 513 | $email = trim( $recipient['email'] ); |