| @@ -89,8 +89,9 @@ | ||
| 89 | 89 | 'active_license' => FrmAppHelper::pro_is_installed(), |
| 90 | 90 | 'form_count' => $form_counts->published, |
| 91 | 91 | 'entry_count' => FrmEntry::getRecordCount(), |
| 92 | 92 | 'timestamp' => gmdate( 'c' ), |
| 93 | + 'misc' => array(), | |
| 93 | 94 | |
| 94 | 95 | 'theme_name' => is_object( $theme_data ) ? $theme_data->Name : '', // phpcs:ignore WordPress.NamingConventions |
| 95 | 96 | 'plugins' => $this->plugins(), |
| 96 | 97 | 'settings' => array( |
| @@ -223,9 +224,9 @@ | ||
| 223 | 224 | continue; |
| 224 | 225 | } |
| 225 | 226 | |
| 226 | 227 | // If key ends with `_email`, or value contains `@`, this might contain an email address. |
| 227 | - if ( str_ends_with( $key, '_email' ) || str_contains( $value, '@' ) ) { | |
| 228 | + if ( str_ends_with( $key, '_email' ) || ( is_string( $value ) && str_contains( $value, '@' ) ) ) { | |
| 228 | 229 | // Replace it with a placeholder. |
| 229 | 230 | $value = '{{contain_email}}'; |
| 230 | 231 | } |
| 231 | 232 | }//end foreach |
| @@ -266,24 +267,13 @@ | ||
| 266 | 267 | */ |
| 267 | 268 | private function payments( $table = 'frm_payments' ) { |
| 268 | 269 | $allowed_tables = array( 'frm_payments', 'frm_subscriptions' ); |
| 269 | 270 | |
| 270 | - if ( ! in_array( $table, $allowed_tables, true ) ) { | |
| 271 | + if ( ! in_array( $table, $allowed_tables, true ) || ! FrmTransLiteAppHelper::payments_table_exists() ) { | |
| 271 | 272 | return array(); |
| 272 | 273 | } |
| 273 | 274 | |
| 274 | - if ( ! FrmTransLiteAppHelper::payments_table_exists() ) { | |
| 275 | - return array(); | |
| 276 | - } | |
| 277 | - | |
| 278 | - global $wpdb; | |
| 279 | - $rows = $wpdb->get_results( | |
| 280 | - $wpdb->prepare( | |
| 281 | - 'SELECT amount, status, paysys, created_at FROM %1$s', | |
| 282 | - $wpdb->prefix . $table | |
| 283 | - ) | |
| 284 | - ); | |
| 285 | - | |
| 275 | + $rows = $this->get_payment_db_rows( $table ); | |
| 286 | 276 | $payments = array(); |
| 287 | 277 | |
| 288 | 278 | foreach ( $rows as $row ) { |
| 289 | 279 | $payments[] = array( |
| @@ -297,8 +287,36 @@ | ||
| 297 | 287 | return $payments; |
| 298 | 288 | } |
| 299 | 289 | |
| 300 | 290 | /** |
| 291 | + * @since 6.30 | |
| 292 | + * | |
| 293 | + * @param string $table | |
| 294 | + * | |
| 295 | + * @return array | |
| 296 | + */ | |
| 297 | + private function get_payment_db_rows( $table ) { | |
| 298 | + global $wpdb; | |
| 299 | + | |
| 300 | + if ( FrmDb::db_column_exists( $table, 'test' ) ) { | |
| 301 | + return $wpdb->get_results( | |
| 302 | + $wpdb->prepare( | |
| 303 | + 'SELECT amount, status, paysys, created_at FROM %i WHERE test IS NULL OR test != 1', | |
| 304 | + $wpdb->prefix . $table | |
| 305 | + ) | |
| 306 | + ); | |
| 307 | + } | |
| 308 | + | |
| 309 | + // Fallback for PayPal add-on where this column does not exist. | |
| 310 | + return $wpdb->get_results( | |
| 311 | + $wpdb->prepare( | |
| 312 | + 'SELECT amount, status, paysys, created_at FROM %i', | |
| 313 | + $wpdb->prefix . $table | |
| 314 | + ) | |
| 315 | + ); | |
| 316 | + } | |
| 317 | + | |
| 318 | + /** | |
| 301 | 319 | * @since 3.06.04 |
| 302 | 320 | * |
| 303 | 321 | * @return array |
| 304 | 322 | */ |
| @@ -584,24 +602,43 @@ | ||
| 584 | 602 | * |
| 585 | 603 | * @return array |
| 586 | 604 | */ |
| 587 | 605 | private function actions() { |
| 588 | - $args = array( | |
| 589 | - 'post_type' => FrmFormActionsController::$action_post_type, | |
| 590 | - 'numberposts' => 100, | |
| 591 | - ); | |
| 606 | + $actions = array(); | |
| 607 | + $offset = 0; | |
| 608 | + $limit = 100; | |
| 609 | + $limit_plus_one = $limit + 1; | |
| 592 | 610 | |
| 593 | - $actions = array(); | |
| 594 | - $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; | |
| 595 | 619 | |
| 596 | - foreach ( $saved_actions as $action ) { | |
| 597 | - $actions[] = array( | |
| 598 | - 'form_id' => $action->menu_order, | |
| 599 | - 'type' => $action->post_excerpt, | |
| 600 | - 'status' => $action->post_status, | |
| 601 | - 'settings' => FrmAppHelper::maybe_json_decode( $action->post_content ), | |
| 602 | - ); | |
| 603 | - } | |
| 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 ); | |
| 604 | 641 | |
| 605 | 642 | return $actions; |
| 606 | 643 | } |
| 607 | 644 | |