| @@ -224,9 +224,9 @@ | ||
| 224 | 224 | continue; |
| 225 | 225 | } |
| 226 | 226 | |
| 227 | 227 | // If key ends with `_email`, or value contains `@`, this might contain an email address. |
| 228 | - if ( str_ends_with( $key, '_email' ) || str_contains( $value, '@' ) ) { | |
| 228 | + if ( str_ends_with( $key, '_email' ) || ( is_string( $value ) && str_contains( $value, '@' ) ) ) { | |
| 229 | 229 | // Replace it with a placeholder. |
| 230 | 230 | $value = '{{contain_email}}'; |
| 231 | 231 | } |
| 232 | 232 | }//end foreach |
| @@ -602,24 +602,43 @@ | ||
| 602 | 602 | * |
| 603 | 603 | * @return array |
| 604 | 604 | */ |
| 605 | 605 | private function actions() { |
| 606 | - $args = array( | |
| 607 | - 'post_type' => FrmFormActionsController::$action_post_type, | |
| 608 | - 'numberposts' => 100, | |
| 609 | - ); | |
| 606 | + $actions = array(); | |
| 607 | + $offset = 0; | |
| 608 | + $limit = 100; | |
| 609 | + $limit_plus_one = $limit + 1; | |
| 610 | 610 | |
| 611 | - $actions = array(); | |
| 612 | - $saved_actions = FrmDb::check_cache( json_encode( $args ), 'frm_actions', $args, 'get_posts' ); | |
| 611 | + do { | |
| 612 | + $args = array( | |
| 613 | + 'post_type' => FrmFormActionsController::$action_post_type, | |
| 614 | + 'numberposts' => $limit_plus_one, | |
| 615 | + 'offset' => $offset, | |
| 616 | + ); | |
| 617 | + $saved_actions = get_posts( $args ); | |
| 618 | + $has_more = count( $saved_actions ) === $limit_plus_one; | |
| 613 | 619 | |
| 614 | - foreach ( $saved_actions as $action ) { | |
| 615 | - $actions[] = array( | |
| 616 | - 'form_id' => $action->menu_order, | |
| 617 | - 'type' => $action->post_excerpt, | |
| 618 | - 'status' => $action->post_status, | |
| 619 | - 'settings' => FrmAppHelper::maybe_json_decode( $action->post_content ), | |
| 620 | - ); | |
| 621 | - } | |
| 620 | + if ( $has_more ) { | |
| 621 | + // Pop off the last item as it is only queried to determine if there are more results. | |
| 622 | + array_pop( $saved_actions ); | |
| 623 | + } | |
| 624 | + | |
| 625 | + foreach ( $saved_actions as $action ) { | |
| 626 | + $actions[] = array( | |
| 627 | + 'form_id' => $action->menu_order, | |
| 628 | + 'type' => $action->post_excerpt, | |
| 629 | + 'status' => $action->post_status, | |
| 630 | + 'settings' => FrmAppHelper::maybe_json_decode( $action->post_content ), | |
| 631 | + ); | |
| 632 | + unset( $action ); | |
| 633 | + } | |
| 634 | + | |
| 635 | + $offset += $limit; | |
| 636 | + | |
| 637 | + unset( $saved_actions ); | |
| 638 | + | |
| 639 | + gc_collect_cycles(); | |
| 640 | + } while ( $has_more ); | |
| 622 | 641 | |
| 623 | 642 | return $actions; |
| 624 | 643 | } |
| 625 | 644 | |