PluginProbe
WP Data Access – App Builder for Tables, Forms, Charts, Maps & Dashboards / 5.5.85
WP Data Access – App Builder for Tables, Forms, Charts, Maps & Dashboards v5.5.85
5.5.85 5.5.84 5.5.83 5.5.82 5.5.81 5.5.80 5.5.79 5.5.77 5.5.76 5.5.75 5.5.73 5.5.72 5.5.22 5.5.23 5.5.29 5.5.3 5.5.31 5.5.32 5.5.34 5.5.35 5.5.36 5.5.37 5.5.4 5.5.40 5.5.41 All 161 releases
← All changes | WPDataAccess/Utilities/WPDA_Export_Sql.php +31 -24 5.5.3 → 5.5.85 View file →
@@ -113,9 +113,9 @@
113 113 $current_memory_limit = @ini_get( 'memory_limit' );
114 114 if ( false === $current_memory_limit ||
115 115 WPDA::convert_memory_to_decimal( $current_memory_limit ) < WPDA::convert_memory_to_decimal( $wp_memory_limit )
116 116 ) {
117 - @ini_set( 'memory_limit', $wp_memory_limit );
117 + @ini_set( 'memory_limit', $wp_memory_limit ); // phpcs:ignore
118 118 }
119 119 }
120 120
121 121 $this->export_with_prefix = 'on' === WPDA::get_option( WPDA::OPTION_BE_EXPORT_VARIABLE_PREFIX );
@@ -150,9 +150,10 @@
150 150
151 151 if ( '' !== $schema_name ) {
152 152 $wpdadb = WPDADB::get_db_connection( $schema_name );
153 153 if ( null === $wpdadb ) {
154 - die( sprintf( __( 'ERROR - Remote database %s not available', 'wp-data-access' ), esc_attr( $this->schema_name ) ) );
154 + /* translators: %s = database name */
155 + die( sprintf( esc_attr__( 'ERROR - Remote database %s not available', 'wp-data-access' ), esc_attr( $this->schema_name ) ) );
155 156 }
156 157
157 158 $this->schema_name = $schema_name;
158 159 $this->schema_name_prefix = "`{$wpdadb->dbname}`.";
@@ -183,13 +184,16 @@
183 184 */
184 185 public function export() {
185 186 // Check if export is allowed.
186 187 $table_names = isset( $_REQUEST['table_names'] ) ?
187 - json_encode( WPDA::sanitize_text_field_array( $_REQUEST['table_names'] ) ) : ''; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput
188 + json_encode( WPDA::sanitize_text_field_array( $_REQUEST['table_names'] ) ) : ''; // phpcs:ignore
188 189 $wp_nonce = isset( $_REQUEST['_wpnonce'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['_wpnonce'] ) ) : '?'; // input var okay.
189 190 if (
190 191 ! wp_verify_nonce( $wp_nonce, "wpda-export-{$table_names}" ) &&
191 - ! wp_verify_nonce( $wp_nonce, 'wpda-export-' . WPDA::get_current_user_login() )
192 + ! (
193 + WPDA::current_user_is_admin() && // Admins are allowed to export all tables
194 + wp_verify_nonce( $wp_nonce, 'wpda-export-' . WPDA::get_current_user_login() )
195 + )
192 196 ) {
193 197 wp_die();
194 198 }
195 199
@@ -347,12 +351,13 @@
347 351 if ( 'off' !== $this->show_create ) {
348 352 $engine = WPDA::get_table_engine( $this->schema_name, $table_name );
349 353 if ( 'connect' === strtolower( $engine ) ) {
350 354 // Remove table options for CONNECT tables
351 - $wpdadb->query( "SET sql_mode = 'NO_TABLE_OPTIONS'" );
355 + // NO_TABLE_OPTIONS is deprecated in V8
356 + // $wpdadb->query( "SET sql_mode = 'NO_TABLE_OPTIONS'" );
352 357 }
353 358 $query = "show create table {$this->schema_name_prefix}`" . str_replace( '`', '', (string) $table_name ) . '`';
354 - $ctcmd = $wpdadb->get_results( $query, 'ARRAY_A' ); // phpcs:ignore Standard.Category.SniffName.ErrorCode
359 + $ctcmd = $wpdadb->get_results( $query, 'ARRAY_A' );
355 360 }
356 361
357 362 $this->output_string = '';
358 363 if ( $wpdadb->num_rows > 0 ) {
@@ -391,9 +396,9 @@
391 396 $table_exists = true;
392 397 } else {
393 398 if ( 'off' !== $this->show_comments ) {
394 399 $this->output_string .= "--\n";
395 - $this->output_string .= '-- Table `' . esc_attr( $table_name ) . "` not found\n";
400 + $this->output_string .= '-- Table `' . esc_attr( $table_name ) . "` found\n";
396 401 $this->output_string .= "--\n\n";
397 402 }
398 403
399 404 $table_exists = false;
@@ -439,18 +444,20 @@
439 444 $this->output_string = '';
440 445
441 446 $query = "select * from {$this->schema_name_prefix}`" . str_replace( '`', '', (string) $table_name ) . "` $where";
442 447 if ( is_numeric( $query_buffer_size ) && $query_buffer_size > 0 ) {
448 + // phpcs:disable Squiz.PHP.DiscouragedFunctions.Discouraged
443 449 set_time_limit(0);
450 + // phpcs:enable Squiz.PHP.DiscouragedFunctions.Discouraged
444 451 $i = 0;
445 452 $sql = $query . ' limit ' . $query_buffer_size;
446 - $rows = $wpdadb->get_results( $sql, 'ARRAY_A' ); // phpcs:ignore Standard.Category.SniffName.ErrorCode
453 + $rows = $wpdadb->get_results( $sql, 'ARRAY_A' );
447 454 while ( $wpdadb->num_rows > 0 ) {
448 455 $this->insert_rows_buffer( $rows, $table_name, $where, $show_comments );
449 456
450 457 $i++;
451 458 $sql = $query . ' limit ' . $query_buffer_size . ' offset ' . ( $i * $query_buffer_size );
452 - $rows = $wpdadb->get_results( $sql, 'ARRAY_A' ); // phpcs:ignore Standard.Category.SniffName.ErrorCode
459 + $rows = $wpdadb->get_results( $sql, 'ARRAY_A' );
453 460 }
454 461
455 462 if ( 1 === $i && 0 == $wpdadb->num_rows ) {
456 463 $this->empty_table( $table_name, $show_comments );
@@ -455,9 +462,9 @@
455 462 if ( 1 === $i && 0 == $wpdadb->num_rows ) {
456 463 $this->empty_table( $table_name, $show_comments );
457 464 }
458 465 } else {
459 - $rows = $wpdadb->get_results( $query, 'ARRAY_A' ); // phpcs:ignore Standard.Category.SniffName.ErrorCode
466 + $rows = $wpdadb->get_results( $query, 'ARRAY_A' );
460 467
461 468 if ( $wpdadb->num_rows > 0 ) {
462 469 $this->insert_rows_buffer( $rows, $table_name, $where, $show_comments );
463 470 } else {
@@ -562,10 +569,10 @@
562 569
563 570 foreach ( $rows as $row ) {
564 571 $this->output_string .= $insert_statement . '(';
565 572
566 - $keys = array_keys( $row );//phpcs:ignore - 8.1 proof
567 - $last_column = end( $keys );//phpcs:ignore - 8.1 proof
573 + $keys = array_keys( $row ); // phpcs:ignore -- 8.1 proof
574 + $last_column = end( $keys ); // phpcs:ignore -- 8.1 proof
568 575 foreach ( $row as $column_name => $column_value ) {
569 576 if (
570 577 ! (
571 578 WPDA::is_wpda_table( $table_name ) &&
@@ -637,9 +644,9 @@
637 644 }
638 645
639 646 if ( 'on' === $this->include_table_settings ) {
640 647 // Export column labels
641 - $rows = $wpdb->get_results(
648 + $rows = $wpdb->get_results( // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- plugin table
642 649 $wpdb->prepare(
643 650 "select * from {$wpdb->prefix}wpda_table_settings where wpda_table_name = %s",
644 651 array(
645 652 $table_name,
@@ -645,9 +652,9 @@
645 652 $table_name,
646 653 )
647 654 ),
648 655 'ARRAY_A'
649 - ); // phpcs:ignore Standard.Category.SniffName.ErrorCode
656 + );
650 657 if ( 1 === $wpdb->num_rows ) {
651 658 $this->output_string .=
652 659 'DELETE FROM `{wp_prefix}wpda_table_settings` ' .
653 660 "WHERE `wpda_table_name` = '" . esc_attr( $table_name ) . "';";
@@ -661,9 +668,9 @@
661 668 $this->output_string .= "\n";
662 669 }
663 670
664 671 // Export media columns
665 - $rows = $wpdb->get_results(
672 + $rows = $wpdb->get_results( // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- plugin table
666 673 $wpdb->prepare(
667 674 "select * from {$wpdb->prefix}wpda_media where media_table_name = %s",
668 675 array(
669 676 $table_name,
@@ -669,9 +676,9 @@
669 676 $table_name,
670 677 )
671 678 ),
672 679 'ARRAY_A'
673 - ); // phpcs:ignore Standard.Category.SniffName.ErrorCode
680 + );
674 681 $this->output_string .=
675 682 'DELETE FROM `{wp_prefix}wpda_media` ' .
676 683 "WHERE `media_table_name` = '" . esc_attr( $table_name ) . "';";
677 684 $this->output_string .= "\n";
@@ -686,9 +693,9 @@
686 693 $this->output_string .= "\n";
687 694 }
688 695
689 696 // Export table menus
690 - $rows = $wpdb->get_results(
697 + $rows = $wpdb->get_results( // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- plugin table
691 698 $wpdb->prepare(
692 699 "select * from {$wpdb->prefix}wpda_menus where menu_table_name = %s",
693 700 array(
694 701 $table_name,
@@ -694,9 +701,9 @@
694 701 $table_name,
695 702 )
696 703 ),
697 704 'ARRAY_A'
698 - ); // phpcs:ignore Standard.Category.SniffName.ErrorCode
705 + );
699 706 $this->output_string .=
700 707 'DELETE FROM `{wp_prefix}wpda_menus` ' .
701 708 "WHERE `menu_table_name` = '" . esc_attr( $table_name ) . "';";
702 709 $this->output_string .= "\n";
@@ -818,9 +825,9 @@
818 825
819 826 // Use first column of the primary key to loop through arguments. Add additional arguments in the loop.
820 827 // A mismatch in the number of argument is possible as long as the columns match based on the first column
821 828 // of the primary key. Other mismatches won't be taken into account.
822 - $count_pk = count( ( array ) $_REQUEST[ $table_primary_key[0] ] );//phpcs:ignore - 8.1 proof
829 + $count_pk = count( ( array ) $_REQUEST[ $table_primary_key[0] ] ); // phpcs:ignore -- 8.1 proof
823 830 for ( $i = 0; $i < $count_pk; $i ++ ) {
824 831 $and = '';
825 832 foreach ( $table_primary_key as $key ) {
826 833 $and .= '' === $and ? '(' : ' and ';
@@ -828,19 +835,19 @@
828 835 $and .= $wpdb->prepare(
829 836 '`%1s` = %d', // phpcs:ignore WordPress.DB.PreparedSQLPlaceholders
830 837 array(
831 838 WPDA::remove_backticks( $key ),
832 - sanitize_text_field( wp_unslash( $_REQUEST[ $key ][ $i ] ) ),
839 + sanitize_text_field( wp_unslash( $_REQUEST[ $key ][ $i ] ) ), // phpcs:ignore -- nonce veryfied in export function
833 840 )
834 - ); // phpcs:ignore Standard.Category.SniffName.ErrorCode
841 + );
835 842 } else {
836 843 $and .= $wpdb->prepare(
837 844 '`%1s` = %s', // phpcs:ignore WordPress.DB.PreparedSQLPlaceholders
838 845 array(
839 846 WPDA::remove_backticks( $key ),
840 - sanitize_text_field( wp_unslash( $_REQUEST[ $key ][ $i ] ) ),
847 + sanitize_text_field( wp_unslash( $_REQUEST[ $key ][ $i ] ) ), // phpcs:ignore -- nonce veryfied in export function
841 848 )
842 - ); // phpcs:ignore Standard.Category.SniffName.ErrorCode
849 + );
843 850 }
844 851 }
845 852
846 853 $and .= '' === $and ? '' : ')';
@@ -876,9 +883,9 @@
876 883 protected function write_output() {
877 884 if ( null === $this->output_stream ) {
878 885 echo $this->output_string; // phpcs:ignore WordPress.Security.EscapeOutput
879 886 } else {
880 - fwrite( $this->output_stream, $this->output_string );
887 + fwrite( $this->output_stream, $this->output_string ); // phpcs:ignore
881 888 }
882 889 $this->output_string = '';
883 890 }
884 891