PluginProbe
WP Data Access – App Builder for Tables, Forms, Charts, Maps & Dashboards / 5.5.84
WP Data Access – App Builder for Tables, Forms, Charts, Maps & Dashboards v5.5.84
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 5.5.42 All 160 releases
← All changes | WPDataAccess/API/WPDA_Actions.php +24 -19 5.5.765.5.84 View file →
@@ -190,8 +190,9 @@
190 190
191 191 public static function get_row_count( $dbs, $tbl ) {
192 192 $wpdadb = WPDADB::get_db_connection( $dbs );
193 193 if ( null === $wpdadb ) {
194 + /* translators: %s = database name */
194 195 return sprintf( __( 'Database %s not available', 'wp-data-access' ), esc_attr( $dbs ) );
195 196 }
196 197 $suppress_errors = $wpdadb->suppress_errors;
197 198 $wpdadb->suppress_errors = true;
@@ -230,12 +231,10 @@
230 231 if ( 0 === count( $files ) || '' === trim( $dbs ) ) {
231 232 return $this->bad_request();
232 233 } else {
233 234 foreach ( $files as $file ) {
234 - // phpcs:disable
235 235 $temp_file_name = sanitize_text_field( $file['tmp_name'] );
236 236 // For Windows: do NOT unslash!
237 - // phpcs:enable
238 237 $temp_file_type = sanitize_text_field( wp_unslash( $file['type'] ) );
239 238 $orig_file_name = sanitize_text_field( wp_unslash( $file['name'] ) );
240 239 if ( 0 === $file['error'] && is_uploaded_file( $temp_file_name ) ) {
241 240 if ( 'application/zip' === $temp_file_type || 'application/x-zip' === $temp_file_type || 'application/x-zip-compressed' === $temp_file_type ) {
@@ -259,8 +258,9 @@
259 258 }
260 259 } else {
261 260 // Error reading ZIP file.
262 261 $errors = true;
262 + // phpcs:disable WordPress.WP.I18n.MissingTranslatorsComment
263 263 $response[] = array(
264 264 $orig_file_name => array(
265 265 'status' => 'error',
266 266 'msg' => sprintf( __( 'Import failed [error reading ZIP file `%s`]', 'wp-data-access' ), $orig_file_name ),
@@ -265,8 +265,9 @@
265 265 'status' => 'error',
266 266 'msg' => sprintf( __( 'Import failed [error reading ZIP file `%s`]', 'wp-data-access' ), $orig_file_name ),
267 267 ),
268 268 );
269 + // phpcs:enable WordPress.WP.I18n.MissingTranslatorsComment
269 270 }
270 271 } else {
271 272 // ZipArchive not installed.
272 273 $errors = true;
@@ -272,15 +273,17 @@
272 273 $errors = true;
273 274 $response[] = array(
274 275 $orig_file_name => array(
275 276 'status' => 'error',
276 - 'msg' => sprintf( __( 'Import failed - ZipArchive not installed %s', 'wp-data-access' ) ),
277 + 'msg' => __( 'Import failed - ZipArchive not installed', 'wp-data-access' ),
277 278 ),
278 279 );
279 280 }
280 281 } else {
281 282 // Process plain file.
283 + // phpcs:disable WordPress.WP.AlternativeFunctions.file_system_operations_fopen
282 284 $this->file_pointer = fopen( $temp_file_name, 'rb' );
285 + // phpcs:enable WordPress.WP.AlternativeFunctions.file_system_operations_fopen
283 286 $status = $this->import( $orig_file_name, $dbs );
284 287 if ( isset( $status['status'], $status['msg'] ) ) {
285 288 $errors = $errors || 'error' === $status['status'];
286 289 $response[] = array(
@@ -472,8 +475,9 @@
472 475 return 'Unauthorized';
473 476 }
474 477 $wpdadb = WPDADB::get_db_connection( $dbs );
475 478 if ( null === $wpdadb ) {
479 + /* translators: %s = database name */
476 480 return sprintf( __( 'Remote database %s not available', 'wp-data-access' ), esc_attr( $dbs ) );
477 481 }
478 482 $suppress_errors = $wpdadb->suppress_errors;
479 483 $wpdadb->suppress_errors = true;
@@ -495,12 +499,14 @@
495 499 return 'Unauthorized';
496 500 }
497 501 $wpdadb_from = WPDADB::get_db_connection( $from_dbs );
498 502 if ( null === $wpdadb_from ) {
503 + /* translators: %s = database name */
499 504 return sprintf( __( 'Remote database %s not available', 'wp-data-access' ), esc_attr( $from_dbs ) );
500 505 }
501 506 $wpdadb_to = WPDADB::get_db_connection( $to_dbs );
502 507 if ( null === $wpdadb_to ) {
508 + /* translators: %s = database name */
503 509 return sprintf( __( 'Remote database %s not available', 'wp-data-access' ), esc_attr( $to_dbs ) );
504 510 }
505 511 $suppress_errors_from = $wpdadb_from->suppress_errors;
506 512 $wpdadb_from->suppress_errors = true;
@@ -544,10 +550,12 @@
544 550 return $wpdadb_to->last_error;
545 551 }
546 552 if ( '1' === $copy_data ) {
547 553 // Copy data from source to destination table.
554 + // Prevent time out.
555 + // phpcs:disable Squiz.PHP.DiscouragedFunctions.Discouraged
548 556 set_time_limit( 0 );
549 - // Prevent time out.
557 + // phpcs:enable Squiz.PHP.DiscouragedFunctions.Discouraged
550 558 // Buffer rows to prevent exhausting memory.
551 559 $buffer_size = 1000;
552 560 // Default buffer
553 561 $settings_db = WPDA_Table_Settings_Model::query( $from_tbl, $from_dbs );
@@ -637,8 +645,9 @@
637 645 return 'Unauthorized';
638 646 }
639 647 $wpdadb = WPDADB::get_db_connection( $dbs );
640 648 if ( null === $wpdadb ) {
649 + /* translators: %s = database name */
641 650 return sprintf( __( 'Remote database %s not available', 'wp-data-access' ), esc_attr( $dbs ) );
642 651 }
643 652 $suppress_errors = $wpdadb->suppress_errors;
644 653 $wpdadb->suppress_errors = true;
@@ -653,8 +662,9 @@
653 662 return 'Unauthorized';
654 663 }
655 664 $wpdadb = WPDADB::get_db_connection( $dbs );
656 665 if ( null === $wpdadb ) {
666 + /* translators: %s = database name */
657 667 return sprintf( __( 'Remote database %s not available', 'wp-data-access' ), esc_attr( $dbs ) );
658 668 }
659 669 $suppress_errors = $wpdadb->suppress_errors;
660 670 $wpdadb->suppress_errors = true;
@@ -673,26 +683,15 @@
673 683
674 684 private function post_drop_table( $dbs, $tbl ) {
675 685 global $wpdb;
676 686 $suppress = $wpdb->suppress_errors( true );
687 + // phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQLPlaceholders, WordPress.DB.PreparedSQLPlaceholders.UnquotedComplexPlaceholder -- plugin table
677 688 // Table settings...
678 - $wpdb->query( $wpdb->prepare(
679 - 'delete from `%1s` where wpda_schema_name = %s and wpda_table_name = %s ',
680 - // phpcs:ignore WordPress.DB.PreparedSQLPlaceholders
681 - array(WPDA::remove_backticks( WPDA_Table_Settings_Model::get_base_table_name() ), $dbs, $tbl)
682 - ) );
689 + $wpdb->query( $wpdb->prepare( 'delete from `%1s` where wpda_schema_name = %s and wpda_table_name = %s ', array(WPDA::remove_backticks( WPDA_Table_Settings_Model::get_base_table_name() ), $dbs, $tbl) ) );
683 690 // WordPress media library columns...
684 - $wpdb->query( $wpdb->prepare(
685 - 'delete from `%1s` where media_schema_name = %s and media_table_name = %s ',
686 - // phpcs:ignore WordPress.DB.PreparedSQLPlaceholders
687 - array(WPDA::remove_backticks( WPDA_Media_Model::get_base_table_name() ), $dbs, $tbl)
688 - ) );
691 + $wpdb->query( $wpdb->prepare( 'delete from `%1s` where media_schema_name = %s and media_table_name = %s ', array(WPDA::remove_backticks( WPDA_Media_Model::get_base_table_name() ), $dbs, $tbl) ) );
689 692 // Data menus...
690 - $wpdb->query( $wpdb->prepare(
691 - 'delete from `%1s` where menu_schema_name = %s and menu_table_name = %s ',
692 - // phpcs:ignore WordPress.DB.PreparedSQLPlaceholders
693 - array(WPDA::remove_backticks( WPDA_User_Menus_Model::get_base_table_name() ), $dbs, $tbl)
694 - ) );
693 + $wpdb->query( $wpdb->prepare( 'delete from `%1s` where menu_schema_name = %s and menu_table_name = %s ', array(WPDA::remove_backticks( WPDA_User_Menus_Model::get_base_table_name() ), $dbs, $tbl) ) );
695 694 $wpdb->suppress_errors( $suppress );
696 695 }
697 696
698 697 private function import( $file_name, $dbs ) {
@@ -705,17 +704,21 @@
705 704 $errors = array();
706 705 global $wpdb;
707 706 $wpdadb = WPDADB::get_db_connection( $dbs );
708 707 if ( null === $wpdadb ) {
708 + // phpcs:disable WordPress.WP.I18n.MissingTranslatorsComment
709 709 return array(
710 710 'status' => 'error',
711 711 'msg' => sprintf( __( 'ERROR - Remote database %s not available', 'wp-data-access' ), esc_attr( $dbs ) ),
712 712 );
713 + // phpcs:enable WordPress.WP.I18n.MissingTranslatorsComment
713 714 }
714 715 $suppress = $wpdadb->suppress_errors( true );
715 716 if ( false !== $this->file_pointer ) {
716 717 while ( !feof( $this->file_pointer ) ) {
718 + // phpcs:disable WordPress.WP.AlternativeFunctions.file_system_operations_fread
717 719 $this->file_content .= fread( $this->file_pointer, 4096 );
720 + // phpcs:enable WordPress.WP.AlternativeFunctions.file_system_operations_fread
718 721 // Replace WP prefix and WPDA prefix.
719 722 $this->file_content = str_replace( '{wp_schema}', $wpdb->dbname, $this->file_content );
720 723 $this->file_content = str_replace( '{wp_prefix}', $wpdb->prefix, $this->file_content );
721 724 $this->file_content = str_replace( '{wpda_prefix}', 'wpda', $this->file_content );
@@ -745,8 +748,9 @@
745 748 }
746 749 }
747 750 $wpdadb->suppress_errors( $suppress );
748 751 // Process file content.
752 + // phpcs:disable WordPress.WP.I18n.MissingTranslatorsComment
749 753 if ( 0 < count( $errors ) ) {
750 754 return array(
751 755 'status' => 'error',
752 756 'msg' => sprintf( __( 'Import `%s` failed [check import file]', 'wp-data-access' ), $file_name ),
@@ -759,7 +763,8 @@
759 763 'msg' => sprintf( __( 'Import `%s` completed succesfully', 'wp-data-access' ), $file_name ),
760 764 'errors' => $errors,
761 765 );
762 766 }
767 + // phpcs:enable WordPress.WP.I18n.MissingTranslatorsComment
763 768 }
764 769
765 770 }