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/Plugin_Table_Models/WPDP_Project_Design_Table_Model.php +57 -61 5.5.375.5.84 View file →
@@ -5,8 +5,9 @@
5 5 *
6 6 * @package WPDataAccess\Plugin_Table_Models
7 7 */
8 8
9 +// phpcs:disable WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing -- verified on page
9 10 namespace WPDataAccess\Plugin_Table_Models {
10 11
11 12 use WPDataAccess\Data_Dictionary\WPDA_List_Columns_Cache;
12 13 use WPDataAccess\Utilities\WPDA_Message_Box;
@@ -87,27 +88,27 @@
87 88 */
88 89 public function __construct() {
89 90 $this->table_name = self::get_base_table_name();
90 91
91 - if ( isset( $_REQUEST['wpda_schema_name'] ) ) {
92 - $this->wpda_schema_name = sanitize_text_field( wp_unslash( $_REQUEST['wpda_schema_name'] ) );
92 + if ( isset( $_REQUEST['wpda_schema_name'] ) ) { // phpcs:ignore
93 + $this->wpda_schema_name = sanitize_text_field( wp_unslash( $_REQUEST['wpda_schema_name'] ) ); // phpcs:ignore
93 94 }
94 95
95 96 // Watch out for arrays! (array = starting export)
96 - if ( isset( $_REQUEST['wpda_table_name'] ) && ! is_array( $_REQUEST['wpda_table_name'] ) ) {
97 - $this->wpda_table_name = sanitize_text_field( wp_unslash( $_REQUEST['wpda_table_name'] ) );
97 + if ( isset( $_REQUEST['wpda_table_name'] ) && ! is_array( $_REQUEST['wpda_table_name'] ) ) { // phpcs:ignore
98 + $this->wpda_table_name = sanitize_text_field( wp_unslash( $_REQUEST['wpda_table_name'] ) ); // phpcs:ignore
98 99 }
99 100
100 - if ( isset( $_REQUEST['wpda_table_setname'] ) ) {
101 - $this->wpda_table_setname = sanitize_text_field( wp_unslash( $_REQUEST['wpda_table_setname'] ) );
101 + if ( isset( $_REQUEST['wpda_table_setname'] ) ) { // phpcs:ignore
102 + $this->wpda_table_setname = sanitize_text_field( wp_unslash( $_REQUEST['wpda_table_setname'] ) ); // phpcs:ignore
102 103 }
103 104
104 - if ( isset( $_REQUEST['wpda_table_setname_old'] ) ) {
105 - $this->wpda_table_setname_old = sanitize_text_field( wp_unslash( $_REQUEST['wpda_table_setname_old'] ) );
105 + if ( isset( $_REQUEST['wpda_table_setname_old'] ) ) { // phpcs:ignore
106 + $this->wpda_table_setname_old = sanitize_text_field( wp_unslash( $_REQUEST['wpda_table_setname_old'] ) ); // phpcs:ignore
106 107 }
107 108
108 - if ( isset( $_REQUEST['action2'] ) ) {
109 - $this->action2 = sanitize_text_field( wp_unslash( $_REQUEST['action2'] ) );
109 + if ( isset( $_REQUEST['action2'] ) ) { // phpcs:ignore
110 + $this->action2 = sanitize_text_field( wp_unslash( $_REQUEST['action2'] ) ); // phpcs:ignore
110 111 }
111 112 }
112 113
113 114 /**
@@ -129,9 +130,9 @@
129 130 return false;
130 131 }
131 132
132 133 global $wpdb;
133 - $wpda_table_design_raw = $wpdb->get_results(
134 + $wpda_table_design_raw = $wpdb->get_results( // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- plugin table
134 135 $wpdb->prepare(
135 136 'SELECT wpda_table_design FROM `%1s` WHERE wpda_schema_name = %s AND wpda_table_name = %s AND wpda_table_setname = %s', // phpcs:ignore WordPress.DB.PreparedSQLPlaceholders
136 137 array(
137 138 WPDA::remove_backticks( $this->table_name ),
@@ -205,9 +206,9 @@
205 206 $unique_column_names = array();
206 207 foreach ( $this->wpda_table_design->table as $column ) {
207 208 $unique_column_names[ $column->column_name ] = true;
208 209 }
209 - if ( count( $unique_column_names ) !== count( $this->wpda_table_design->table ) ) {//phpcs:ignore - 8.1 proof
210 + if ( count( $unique_column_names ) !== count( $this->wpda_table_design->table ) ) { // phpcs:ignore -- 8.1 proof
210 211 $structure_messages[] = array( 'ERR', 'Column name must be unique within a table' );
211 212 }
212 213 }
213 214
@@ -217,15 +218,15 @@
217 218 $unique_index_names = array();
218 219 foreach ( $this->wpda_table_design->indexes as $index ) {
219 220 $unique_index_names[ $index->index_name ] = true;
220 221 }
221 - if ( count( $unique_index_names ) !== count( $this->wpda_table_design->indexes ) ) {//phpcs:ignore - 8.1 proof
222 + if ( count( $unique_index_names ) !== count( $this->wpda_table_design->indexes ) ) { // phpcs:ignore -- 8.1 proof
222 223 $structure_messages[] = array( 'ERR', 'Index name must be unique within a table' );
223 224 }
224 225 }
225 226
226 227 if ( isset( $this->wpda_table_design->tableform_column_options ) ) {
227 - //phpcs:ignore - 8.1 proof
228 + // phpcs:ignore -- 8.1 proof
228 229 if ( count( $this->wpda_table_design->table ) !== count( $this->wpda_table_design->tableform_column_options ) ) {
229 230 $structure_messages[] = array( 'ERR', 'Invalid structure [run reconcile]' );
230 231 }
231 232 }
@@ -238,32 +239,32 @@
238 239 */
239 240 public function prepare_update() {
240 241 $this->query();
241 242
242 - if ( isset( $_REQUEST['design_mode'] ) ) {
243 - $this->wpda_table_design->design_mode = sanitize_text_field( wp_unslash( $_REQUEST['design_mode'] ) );
243 + if ( isset( $_REQUEST['design_mode'] ) ) { // phpcs:ignore
244 + $this->wpda_table_design->design_mode = sanitize_text_field( wp_unslash( $_REQUEST['design_mode'] ) ); // phpcs:ignore
244 245 }
245 246
246 - if ( isset( $_REQUEST['engine'] ) ) {
247 - $this->wpda_table_design->engine = sanitize_text_field( wp_unslash( $_REQUEST['engine'] ) );
247 + if ( isset( $_REQUEST['engine'] ) ) { // phpcs:ignore
248 + $this->wpda_table_design->engine = sanitize_text_field( wp_unslash( $_REQUEST['engine'] ) ); // phpcs:ignore
248 249 }
249 250
250 - if ( isset( $_REQUEST['collation'] ) ) {
251 - $this->wpda_table_design->collation = sanitize_text_field( wp_unslash( $_REQUEST['collation'] ) );
251 + if ( isset( $_REQUEST['collation'] ) ) { // phpcs:ignore
252 + $this->wpda_table_design->collation = sanitize_text_field( wp_unslash( $_REQUEST['collation'] ) ); // phpcs:ignore
252 253 }
253 254
254 - if ( isset( $_REQUEST['column_name'] ) ) {
255 + if ( isset( $_REQUEST['column_name'] ) ) { // phpcs:ignore
255 256 $this->wpda_table_design->table = $this->get_table_structure();
256 257 } else {
257 - if ( isset( $_REQUEST['submitted_changes'] ) && 'table' === $_REQUEST['submitted_changes'] ) {
258 + if ( isset( $_REQUEST['submitted_changes'] ) && 'table' === $_REQUEST['submitted_changes'] ) { // phpcs:ignore
258 259 $this->wpda_table_design->table = array();
259 260 }
260 261 }
261 262
262 - if ( isset( $_REQUEST['column_names'] ) ) {
263 + if ( isset( $_REQUEST['column_names'] ) ) { // phpcs:ignore
263 264 $this->wpda_table_design->indexes = $this->get_indexes();
264 265 } else {
265 - if ( isset( $_REQUEST['submitted_changes'] ) && 'indexes' === $_REQUEST['submitted_changes'] ) {
266 + if ( isset( $_REQUEST['submitted_changes'] ) && 'indexes' === $_REQUEST['submitted_changes'] ) { // phpcs:ignore
266 267 $this->wpda_table_design->indexes = array();
267 268 }
268 269 }
269 270
@@ -290,26 +291,24 @@
290 291 /**
291 292 * CWG cleared these as being future proof on the assumption that the fields in $_REQUEST are all arrays
292 293 * If that is not a safe assumption, this needs to be heavily revised
293 294 */
294 - //phpcs:ignore - 8.1 proof
295 + // phpcs:ignore -- 8.1 proof
295 296 if ( isset( $_REQUEST['row_num'] ) ) {
296 - $no_columns = count( $_REQUEST['row_num'] );
297 + $no_columns = count( $_REQUEST['row_num'] ); // phpcs:ignore
297 298 if (
298 - isset( $_REQUEST['relation_type'] ) &&
299 - $no_columns === count( $_REQUEST['relation_type'] ) &&
300 - isset( $_REQUEST['source_column_name'] ) &&
301 - $no_columns === count( $_REQUEST['source_column_name'] ) &&
302 - isset( $_REQUEST['target_table_name'] ) &&
303 - $no_columns === count( $_REQUEST['target_table_name'] ) &&
304 - isset( $_REQUEST['target_column_name'] ) &&
305 - $no_columns === count( $_REQUEST['target_column_name'] )
299 + isset( $_REQUEST['relation_type'] ) && $no_columns === count( $_REQUEST['relation_type'] ) && // phpcs:ignore
300 + isset( $_REQUEST['source_column_name'] ) && $no_columns === count( $_REQUEST['source_column_name'] ) && // phpcs:ignore
301 + isset( $_REQUEST['target_table_name'] ) && $no_columns === count( $_REQUEST['target_table_name'] ) && // phpcs:ignore
302 + isset( $_REQUEST['target_column_name'] ) && $no_columns === count( $_REQUEST['target_column_name'] ) // phpcs:ignore
306 303 ) {
307 304 for ( $i = 0; $i < $no_columns; $i ++ ) {
305 + // phpcs:disable WordPress.Security.ValidatedSanitizedInput.InputNotValidated
308 306 $relation_type = sanitize_text_field( wp_unslash( $_REQUEST['relation_type'][ $i ] ) );
309 307 $source_column_name = sanitize_text_field( wp_unslash( $_REQUEST['source_column_name'][ $i ] ) );
310 308 $target_table_name = sanitize_text_field( wp_unslash( $_REQUEST['target_table_name'][ $i ] ) );
311 309 $target_column_name = sanitize_text_field( wp_unslash( $_REQUEST['target_column_name'][ $i ] ) );
310 + // phpcs:enable WordPress.Security.ValidatedSanitizedInput.InputNotValidated
312 311 if ( isset( $_REQUEST['target_schema_name'][ $i ] ) ) {
313 312 $target_schema_name = sanitize_text_field( wp_unslash( $_REQUEST['target_schema_name'][ $i ] ) );
314 313 } else {
315 314 $target_schema_name = '';
@@ -315,10 +314,10 @@
315 314 $target_schema_name = '';
316 315 }
317 316
318 317 if ( 'nm' === $relation_type ) {
319 - if ( isset( $_REQUEST[ 'relation_table_name_' . $i ] ) ) {
320 - $relation_table_name = sanitize_text_field( wp_unslash( $_REQUEST[ 'relation_table_name_' . $i ] ) );
318 + if ( isset( $_REQUEST[ 'relation_table_name_' . $i ] ) ) { // phpcs:ignore
319 + $relation_table_name = sanitize_text_field( wp_unslash( $_REQUEST[ 'relation_table_name_' . $i ] ) ); // phpcs:ignore
321 320 } else {
322 321 $relation_table_name = '';
323 322 }
324 323 if ( trim( $relation_table_name ) === '' ) {
@@ -343,21 +342,18 @@
343 342 ) {
344 343 $source_column_name_array = array();
345 344 $target_column_name_array = array();
346 345
347 - array_push( $source_column_name_array, $source_column_name );//phpcs:ignore - 8.1 proof
348 - array_push( $target_column_name_array, $target_column_name );//phpcs:ignore - 8.1 proof
346 + array_push( $source_column_name_array, $source_column_name ); // phpcs:ignore -- 8.1 proof
347 + array_push( $target_column_name_array, $target_column_name ); // phpcs:ignore -- 8.1 proof
349 348
350 - if ( isset( $_REQUEST['num_source_column_name'][ $i ] ) ) {
351 - $num_source_column_name = sanitize_text_field( wp_unslash( $_REQUEST['num_source_column_name'][ $i ] ) );
349 + if ( isset( $_REQUEST['num_source_column_name'][ $i ] ) ) { // phpcs:ignore
350 + $num_source_column_name = sanitize_text_field( wp_unslash( $_REQUEST['num_source_column_name'][ $i ] ) ); // phpcs:ignore
352 351 if ( is_numeric( $num_source_column_name ) ) {
353 352 for ( $j = 1; $j <= $num_source_column_name; $j ++ ) {
354 - if (
355 - isset( $_REQUEST[ 'source_column_name_' . $i . '_' . $j ] ) &&
356 - isset( $_REQUEST[ 'target_column_name_' . $i . '_' . $j ] )
357 - ) {
358 - array_push( $source_column_name_array, sanitize_text_field( wp_unslash( $_REQUEST[ 'source_column_name_' . $i . '_' . $j ] ) ) );//phpcs:ignore - 8.1 proof
359 - array_push( $target_column_name_array, sanitize_text_field( wp_unslash( $_REQUEST[ 'target_column_name_' . $i . '_' . $j ] ) ) );//phpcs:ignore - 8.1 proof
353 + if (isset( $_REQUEST[ 'source_column_name_' . $i . '_' . $j ] ) && isset( $_REQUEST[ 'target_column_name_' . $i . '_' . $j ] )) {
354 + array_push( $source_column_name_array, sanitize_text_field( wp_unslash( $_REQUEST[ 'source_column_name_' . $i . '_' . $j ] ) ) );
355 + array_push( $target_column_name_array, sanitize_text_field( wp_unslash( $_REQUEST[ 'target_column_name_' . $i . '_' . $j ] ) ) );
360 356 }
361 357 }
362 358 }
363 359 }
@@ -414,20 +410,17 @@
414 410 $this->wpda_table_setname = sanitize_text_field( wp_unslash( $_REQUEST['table_setname'] ) );
415 411 }
416 412
417 413 if ( isset( $_REQUEST['tab_label'] ) ) {
418 - $this->wpda_table_design->tableinfo->tab_label =
419 - sanitize_text_field( wp_unslash( $_REQUEST['tab_label'] ) );
414 + $this->wpda_table_design->tableinfo->tab_label = sanitize_text_field( wp_unslash( $_REQUEST['tab_label'] ) );
420 415 }
421 416
422 417 if ( isset( $_REQUEST['default_where'] ) ) {
423 - $this->wpda_table_design->tableinfo->default_where =
424 - sanitize_text_field( wp_unslash( $_REQUEST['default_where'] ) );
418 + $this->wpda_table_design->tableinfo->default_where = sanitize_text_field( wp_unslash( $_REQUEST['default_where'] ) );
425 419 }
426 420
427 421 if ( isset( $_REQUEST['default_orderby'] ) ) {
428 - $this->wpda_table_design->tableinfo->default_orderby =
429 - sanitize_text_field( wp_unslash( $_REQUEST['default_orderby'] ) );
422 + $this->wpda_table_design->tableinfo->default_orderby = sanitize_text_field( wp_unslash( $_REQUEST['default_orderby'] ) );
430 423 }
431 424
432 425 $settings_db = WPDA_Table_Settings_Model::query( $this->wpda_table_name, $this->wpda_schema_name );
433 426 if ( isset( $settings_db[0]['wpda_table_settings'] ) && '' !== $settings_db[0]['wpda_table_settings'] ) {
@@ -472,12 +465,13 @@
472 465 *
473 466 * @return array|null
474 467 */
475 468 protected function get_column_options_from_request() {
469 + // phpcs:disable WordPress.Security.ValidatedSanitizedInput -- verified in page
476 470 if ( isset( $_REQUEST['list_item_name'] ) ) {
477 471 $tableform_column_options = array();
478 472 $i = 0;
479 - foreach ( $_REQUEST['list_item_name'] as $column_name ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput
473 + foreach ( $_REQUEST['list_item_name'] as $column_name ) {
480 474 $tableform_column_options[] = array(
481 475 'column_name' => $column_name,
482 476 'label' => isset( $_REQUEST[ $column_name ] ) ?
483 477 sanitize_text_field( wp_unslash( $_REQUEST[ $column_name ] ) ) :
@@ -500,8 +494,9 @@
500 494 return $tableform_column_options;
501 495 } else {
502 496 return null;
503 497 }
498 + // phpcs:enable WordPress.Security.ValidatedSanitizedInput
504 499 }
505 500
506 501 /**
507 502 * Reconcile table
@@ -546,9 +541,9 @@
546 541 }
547 542 }
548 543 if ( $column_found ) {
549 544 // Add only column to array that were found in the table definition.
550 - array_push( $new_listtable_column_options, $listtable_column_option );//phpcs:ignore - 8.1 proof
545 + array_push( $new_listtable_column_options, $listtable_column_option ); // phpcs:ignore -- 8.1 proof
551 546 }
552 547 }
553 548 $this->wpda_table_design->listtable_column_options = $new_listtable_column_options;
554 549 $new_tableform_column_options = array();
@@ -560,9 +555,9 @@
560 555 }
561 556 }
562 557 if ( $column_found ) {
563 558 // Add only column to array that were found in the table definition.
564 - array_push( $new_tableform_column_options, $tableform_column_option );//phpcs:ignore - 8.1 proof
559 + array_push( $new_tableform_column_options, $tableform_column_option ); // phpcs:ignore -- 8.1 proof
565 560 }
566 561 }
567 562 $this->wpda_table_design->tableform_column_options = $new_tableform_column_options;
568 563 }
@@ -605,9 +600,9 @@
605 600 }
606 601 }
607 602 global $wpdb;
608 603
609 - return $wpdb->update(
604 + return $wpdb->update( // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- plugin table
610 605 $this->table_name,
611 606 array(
612 607 'wpda_table_design' => json_encode( $this->wpda_table_design ),
613 608 ),
@@ -650,9 +645,9 @@
650 645 */
651 646 public static function get_column_options( $table_name, $label_type, $setname = 'default', $schema_name = '' ) {
652 647 if ( ! isset( self::$cache_table_options[ "$table_name.$setname" ] ) ) {
653 648 global $wpdb;
654 - $table_json = $wpdb->get_results(
649 + $table_json = $wpdb->get_results( // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- plugin table
655 650 $wpdb->prepare(
656 651 "SELECT wpda_table_design FROM `%1s` WHERE wpda_schema_name = %s AND wpda_table_name = %s AND ( wpda_table_setname = %s OR wpda_table_setname = 'default') ORDER BY IF( wpda_table_setname='default', 1 , 0 )", // phpcs:ignore WordPress.DB.PreparedSQLPlaceholders
657 652 array(
658 653 WPDA::remove_backticks( self::get_base_table_name() ),
@@ -661,9 +656,9 @@
661 656 $setname,
662 657 )
663 658 ),
664 659 'ARRAY_A'
665 - ); // phpcs:ignore Standard.Category.SniffName.ErrorCode
660 + );
666 661
667 662 if ( $wpdb->num_rows > 0 ) {
668 663 if ( isset( $table_json[0]['wpda_table_design'] ) ) {
669 664 $table_obj = json_decode( $table_json[0]['wpda_table_design'] );
@@ -750,9 +745,9 @@
750 745 );
751 746 }
752 747
753 748 return (
754 - 1 === $wpdb->insert(
749 + 1 === $wpdb->insert( // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery -- plugin table
755 750 $table_name,
756 751 array(
757 752 'wpda_schema_name' => $wpda_schema_name,
758 753 'wpda_table_name' => $wpda_table_name,
@@ -780,9 +775,9 @@
780 775 $this->wpda_table_setname_old :
781 776 $this->wpda_table_setname;
782 777
783 778 global $wpdb;
784 - $result_update = $wpdb->update(
779 + $result_update = $wpdb->update( // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- plugin table
785 780 $this->table_name,
786 781 array(
787 782 'wpda_table_setname' => $this->wpda_table_setname,
788 783 'wpda_table_design' => json_encode( $this->wpda_table_design ),
@@ -838,9 +833,9 @@
838 833
839 834 protected static function do_static_query( $wpda_schema_name, $wpda_table_name, $wpda_set_name ) {
840 835 global $wpdb;
841 836
842 - return $wpdb->get_results(
837 + return $wpdb->get_results( // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- plugin table
843 838 $wpdb->prepare(
844 839 'SELECT wpda_table_design FROM `%1s` WHERE wpda_schema_name = %s AND wpda_table_name = %s AND wpda_table_setname = %s', // phpcs:ignore WordPress.DB.PreparedSQLPlaceholders
845 840 array(
846 841 WPDA::remove_backticks( self::get_base_table_name() ),
@@ -855,4 +850,5 @@
855 850
856 851 }
857 852
858 853 }
854 +// phpcs:enable WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing