diff --git a/assets/css/settings-styles.css b/assets/css/settings-styles.css index 5ca7df021..82e091917 100644 --- a/assets/css/settings-styles.css +++ b/assets/css/settings-styles.css @@ -275,7 +275,6 @@ table.wcpdf_documents_settings_list td.title { .wcpdf_advanced_numbers_choose_table .number-table-data-info { border-top: 1px solid #eaeaea; - border-bottom: 1px solid #eaeaea; margin-bottom: 20px; } diff --git a/includes/settings/class-wcpdf-settings-debug.php b/includes/settings/class-wcpdf-settings-debug.php index 18e16d984..3bb83b300 100644 --- a/includes/settings/class-wcpdf-settings-debug.php +++ b/includes/settings/class-wcpdf-settings-debug.php @@ -938,47 +938,46 @@ public function fetch_number_table_data( string $table_name, string $orderby = ' $total_limit = 'all' !== $data['limit'] ? absint( $data['limit'] ) : 0; $total_fetched = absint( $total_fetched ?? 0 ); - $chunk_size = 0 !== $total_limit && $total_limit < $chunk_size ? min( $total_limit - $offset, $chunk_size ) : absint( $chunk_size ?? 100 ); $offset = absint( $offset ?? 0 ); + $chunk_size = 0 !== $total_limit ? min( $total_limit - $offset, $chunk_size ) : absint( $chunk_size ?? 100 ); $option_name = "wpo_wcpdf_number_data::{$data['table_name']}"; $results = get_option( $option_name, array() ); $hook = 'wpo_wcpdf_number_table_data_fetch'; - while ( true ) { - $query = $wpdb->prepare( "SELECT * FROM {$data['table_name']} ORDER BY {$data['orderby']} {$data['order']} LIMIT %d OFFSET %d", $chunk_size, $offset ); - $chunk_results = $wpdb->get_results( $query ); - - if ( empty( $chunk_results ) ) { - as_unschedule_all_actions( $hook ); - update_option( $option_name . '::last_time', time() ); - break; // exit the loop if no more results - } - - $results = array_merge( $results, $chunk_results ); // append the chunk results to the main results array - $total_fetched += count( $chunk_results ); // update total fetched rows - - update_option( $option_name, $results ); - - if ( 0 !== $total_limit && $total_fetched >= $total_limit ) { - as_unschedule_all_actions( $hook ); - update_option( $option_name . '::last_time', time() ); - break; // exit the loop if total limit is reached - } - - $offset += $chunk_size; // increase the offset for the next chunk - - $args = array( - 'table_name' => $data['table_name'], - 'orderby' => $data['orderby'], - 'order' => $data['order'], - 'limit' => $data['limit'], - 'chunk_size' => $chunk_size, - 'offset' => $offset, - 'total_fetched' => $total_fetched, - ); - - as_enqueue_async_action( $hook, $args ); + // query + $query = $wpdb->prepare( "SELECT * FROM {$data['table_name']} ORDER BY {$data['orderby']} {$data['order']} LIMIT %d OFFSET %d", $chunk_size, $offset ); + $chunk_results = $wpdb->get_results( $query ); + + if ( empty( $chunk_results ) ) { + as_unschedule_all_actions( $hook ); + update_option( $option_name . '::last_time', time() ); + return; // exit the loop if no more results } + + $results = array_merge( $results, $chunk_results ); // append the chunk results to the main results array + $total_fetched += count( $chunk_results ); // update total fetched rows + + update_option( $option_name, $results ); + + if ( 0 !== $total_limit && $total_fetched >= $total_limit ) { + as_unschedule_all_actions( $hook ); + update_option( $option_name . '::last_time', time() ); + return; // exit the loop if total limit is reached + } + + $offset += $chunk_size; // increase the offset for the next chunk + + $args = array( + 'table_name' => $data['table_name'], + 'orderby' => $data['orderby'], + 'order' => $data['order'], + 'limit' => $data['limit'], + 'chunk_size' => $chunk_size, + 'offset' => $offset, + 'total_fetched' => $total_fetched, + ); + + as_enqueue_async_action( $hook, $args ); } /** diff --git a/includes/views/advanced-numbers.php b/includes/views/advanced-numbers.php index 7a5bbd3bc..24c6eaabe 100644 --- a/includes/views/advanced-numbers.php +++ b/includes/views/advanced-numbers.php @@ -34,7 +34,18 @@
+ ', + '' + ); + ?> +
+