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/Utilities/WPDA_Repository.php +38 -29 5.5.45.5.84 View file →
@@ -71,10 +71,8 @@
71 71 'create_table_app_container.sql',
72 72 ),
73 73 'wpda_app_apps' => array(
74 74 'create_table_app_apps.sql',
75 - 'create_table_app_apps_alter1.sql',
76 - 'create_table_app_apps_alter2.sql',
77 75 ),
78 76 );
79 77
80 78 const DROP_TABLE = array(
@@ -134,9 +132,20 @@
134 132 global $wpdb;
135 133
136 134 $suppress = $wpdb->suppress_errors( true );
137 135
138 - $bck_postfix = WPDA_Restore_Repository::BACKUP_TABLE_EXTENSION . date( 'YmdHis' );
136 + // Remove foreign key constraints on app tables
137 + $wpdb->query( // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- plugin table
138 + "ALTER TABLE {$wpdb->prefix}wpda_app_apps DROP FOREIGN KEY `wp_wpda_app_apps_ibfk_1`" // phpcs:ignore WordPress.DB.DirectDatabaseQuery.SchemaChange
139 + );
140 + $wpdb->query( // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- plugin table
141 + "ALTER TABLE {$wpdb->prefix}wpda_app_apps DROP FOREIGN KEY `wp_wpda_app_apps_ibfk_2`" // phpcs:ignore WordPress.DB.DirectDatabaseQuery.SchemaChange
142 + );
143 + $wpdb->query( // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- plugin table
144 + "AlTER TABLE {$wpdb->prefix}wpda_app_container DROP FOREIGN KEY `wp_wpda_app_container_ibfk_1`" // phpcs:ignore WordPress.DB.DirectDatabaseQuery.SchemaChange
145 + );
146 +
147 + $bck_postfix = WPDA_Restore_Repository::BACKUP_TABLE_EXTENSION . gmdate( 'YmdHis' );
139 148 foreach ( static::CREATE_TABLE as $key => $value ) {
140 149 $table_name = $wpdb->prefix . $key;
141 150
142 151 // Check if table exists
@@ -148,11 +157,11 @@
148 157
149 158 if ( $table_check ) {
150 159 // Create backup table
151 160 $bck_table_name = $wpdb->prefix . $key . $bck_postfix;
152 - $wpdb->query(
161 + $wpdb->query( // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- plugin table
153 162 $wpdb->prepare(
154 - 'create table `%1s` as select * from `%1s`', // phpcs:ignore WordPress.DB.PreparedSQLPlaceholders
163 + 'create table `%1s` as select * from `%1s`', // phpcs:ignore WordPress.DB.PreparedSQLPlaceholders, WordPress.DB.DirectDatabaseQuery.SchemaChange
155 164 array(
156 165 WPDA::remove_backticks( $bck_table_name ),
157 166 WPDA::remove_backticks( $table_name ),
158 167 )
@@ -163,9 +172,9 @@
163 172 if ( $table_check ) {
164 173 // Create temporary table to check for changes
165 174 if ( $this->run_script( $value[0], '_new' ) ) {
166 175 // Check if table structure was changed
167 - $table_diff = $wpdb->get_row(
176 + $table_diff = $wpdb->get_row( // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- plugin table
168 177 $wpdb->prepare(
169 178 'select column_name,ordinal_position,data_type,column_type from (
170 179 select column_name, ordinal_position, data_type, column_type, count(1) rowcount
171 180 from information_schema.columns
@@ -191,10 +200,10 @@
191 200 foreach ( $value as $sql_file ) {
192 201 $this->run_script( $sql_file );
193 202 }
194 203
195 - // Get columns matching old and new repository table columns to restore as much values as possible
196 - $same_cols = $wpdb->get_results(
204 + // Get columns matching old and new repository table columns to restore as many values as possible
205 + $same_cols = $wpdb->get_results( // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- plugin table
197 206 $wpdb->prepare(
198 207 'select c1.column_name as column_name
199 208 from information_schema.columns c1
200 209 where c1.table_schema = %s
@@ -219,9 +228,9 @@
219 228 foreach ( $same_cols as $same_col ) {
220 229 $selected_columns .= $same_col['column_name'] . ',';
221 230 }
222 231 $selected_columns = substr( $selected_columns, 0, strlen( $selected_columns ) - 1 );
223 - $wpdb->query(
232 + $wpdb->query( // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- plugin table
224 233 $wpdb->prepare(
225 234 'insert into `%1s` (%1s) select %1s from `%1s`', // phpcs:ignore WordPress.DB.PreparedSQLPlaceholders
226 235 array(
227 236 WPDA::remove_backticks( $table_name ),
@@ -257,9 +266,9 @@
257 266 $backup_tables_kept = WPDA::get_option( WPDA::OPTION_MR_BACKUP_TABLES_KEPT );
258 267 $base_table_name = WPDA_Publisher_Model::get_base_table_name() . WPDA_Restore_Repository::BACKUP_TABLE_EXTENSION;
259 268
260 269 global $wpdb;
261 - $rows = $wpdb->get_results(
270 + $rows = $wpdb->get_results( // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- plugin table
262 271 $wpdb->prepare(
263 272 '
264 273 select table_name as table_name
265 274 from information_schema.tables
@@ -274,9 +283,9 @@
274 283 ),
275 284 'ARRAY_A'
276 285 );
277 286
278 - for ( $i = $backup_tables_kept; $i < count( $rows ); $i ++ ) {//phpcs:ignore - 8.1 proof
287 + for ( $i = $backup_tables_kept; $i < count( $rows ); $i ++ ) { // phpcs:ignore -- 8.1 proof
279 288 $backup_date = substr( $rows[ $i ]['table_name'], strlen( $base_table_name ) );
280 289 $this->remove_backup( $backup_date );
281 290 }
282 291 }
@@ -288,11 +297,11 @@
288 297
289 298 $suppress = $wpdb->suppress_errors( true );
290 299 $extension = WPDA_Restore_Repository::BACKUP_TABLE_EXTENSION;
291 300 foreach ( self::CREATE_TABLE as $key => $value ) {
292 - $wpdb->query(
301 + $wpdb->query( // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- plugin table
293 302 $wpdb->prepare(
294 - 'drop table `%1s`', // phpcs:ignore WordPress.DB.PreparedSQLPlaceholders
303 + 'drop table `%1s`', // phpcs:ignore WordPress.DB.PreparedSQLPlaceholders, WordPress.DB.DirectDatabaseQuery.SchemaChange
295 304 array(
296 305 WPDA::remove_backticks( "{$wpdb->prefix}{$key}{$extension}{$backup_date_sanitized}" ),
297 306 )
298 307 )
@@ -307,28 +316,28 @@
307 316 protected function cleanup() {
308 317 global $wpdb;
309 318
310 319 // Remove previous data table list table settings
311 - $wpdb->query(
320 + $wpdb->query( // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- plugin table
312 321 "delete from {$wpdb->prefix}usermeta where meta_key like '%columnshidden%' and meta_key like '%wpda_publisher%'"
313 322 );
314 323
315 324 // Remove previous project page list table settings
316 - $wpdb->query(
325 + $wpdb->query( // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- plugin table
317 326 "delete from {$wpdb->prefix}usermeta where meta_key like '%columnshidden%' and meta_key like '%wpda_project%'"
318 327 );
319 328
320 329 // Allow column to contain null values
321 - $wpdb->query(
322 - "alter table {$wpdb->prefix}wpda_project_page modify page_allow_full_export enum('yes','no') null default 'no'"
330 + $wpdb->query( // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- plugin table
331 + "alter table {$wpdb->prefix}wpda_project_page modify page_allow_full_export enum('yes','no') null default 'no'" // phpcs:ignore WordPress.DB.DirectDatabaseQuery.SchemaChange
323 332 );
324 333
325 334 // Remove material sort icons from data tables
326 - $wpdb->query(
335 + $wpdb->query( // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- plugin table
327 336 "update {$wpdb->prefix}wpda_publisher set pub_sort_icons = 'default' where pub_sort_icons = 'plugin'"
328 337 );
329 - $wpdb->query(
330 - "alter table {$wpdb->prefix}wpda_publisher modify pub_sort_icons enum('default','none')"
338 + $wpdb->query( // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- plugin table
339 + "alter table {$wpdb->prefix}wpda_publisher modify pub_sort_icons enum('default','none')" // phpcs:ignore WordPress.DB.DirectDatabaseQuery.SchemaChange
331 340 );
332 341
333 342 // Remove plugin configuration settings: wrong values installed with 5.0.0 (needs to be reset on next deployment)
334 343 delete_option( 'wpda_plugin_navigation' );
@@ -372,14 +381,14 @@
372 381 * @since 2.0.11
373 382 */
374 383 public function run_script( $sql_file, $wpda_postfix = '' ) {
375 384 $sql_repository_file = $this->sql_repository_dir . $sql_file;
376 - $sql_repository_handle = fopen( $sql_repository_file, 'r' );
385 + $sql_repository_handle = fopen( $sql_repository_file, 'r' ); // phpcs:ignore
377 386
378 387 if ( $sql_repository_handle ) {
379 388 // Read file content and close handle.
380 - $sql_repository_file_content = fread( $sql_repository_handle, filesize( $sql_repository_file ) );
381 - fclose( $sql_repository_handle );
389 + $sql_repository_file_content = fread( $sql_repository_handle, filesize( $sql_repository_file ) ); // phpcs:ignore
390 + fclose( $sql_repository_handle ); // phpcs:ignore
382 391
383 392 global $wpdb;
384 393
385 394 // Replace WP prefix and WPDA prefix.
@@ -388,9 +397,9 @@
388 397 $sql_repository_file_content = str_replace( '{wpda_postfix}', $wpda_postfix, $sql_repository_file_content );
389 398 $sql_repository_file_content = str_replace( '{wpda_collate}', $wpdb->get_charset_collate(), $sql_repository_file_content );
390 399
391 400 // Run script from admin/repository.
392 - return $wpdb->query( $sql_repository_file_content ); // phpcs:ignore WordPress.DB.PreparedSQL
401 + return $wpdb->query( $sql_repository_file_content ); // phpcs:ignore -- plugin tables
393 402 }
394 403 }
395 404
396 405
@@ -403,9 +412,9 @@
403 412 if ( ! is_admin() ) {
404 413 return;
405 414 }
406 415
407 - if ( isset( $_REQUEST['setup_error'] ) && 'off' === $_REQUEST['setup_error'] ) {
416 + if ( isset( $_REQUEST['setup_error'] ) && 'off' === $_REQUEST['setup_error'] ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- already verified
408 417 // Turn off menu management not available message.
409 418 WPDA::set_option( WPDA::OPTION_WPDA_SETUP_ERROR, 'off' );
410 419 } else {
411 420 if ( 'off' !== WPDA::get_option( WPDA::OPTION_WPDA_SETUP_ERROR ) ) {
@@ -430,9 +439,9 @@
430 439 '<a href="?page=wpdataaccess&tab=repository">' . __( 'Recreate repository', 'wp-data-access' ) . '</a>' .
431 440 ' ' .
432 441 __( 'to to solve this problem.', 'wp-data-access' ) .
433 442 ' [' .
434 - '<a href="?' . esc_url( sanitize_text_field( wp_unslash( $_SERVER['QUERY_STRING'] ) ) ) . '&setup_error=off">' . __( 'do not show this message again', 'wp-data-access' ) . '</a>' .
443 + '<a href="?' . esc_url( sanitize_text_field( wp_unslash( $_SERVER['QUERY_STRING'] ) ) ) . '&setup_error=off">' . __( 'do not show this message again', 'wp-data-access' ) . '</a>' . // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotValidated
435 444 ']',
436 445 )
437 446 );
438 447
@@ -444,9 +453,9 @@
444 453
445 454 public function create_new_backup() {
446 455 global $wpdb;
447 456
448 - $bck_postfix = WPDA_Restore_Repository::BACKUP_TABLE_EXTENSION . date( 'YmdHis' );
457 + $bck_postfix = WPDA_Restore_Repository::BACKUP_TABLE_EXTENSION . gmdate( 'YmdHis' );
449 458 foreach ( static::CREATE_TABLE as $key => $value ) {
450 459 $table_name = $wpdb->prefix . $key;
451 460
452 461 // Check if table exists
@@ -453,11 +462,11 @@
453 462 $table_exists = new WPDA_Dictionary_Exist( $wpdb->dbname, $table_name );
454 463
455 464 if ( $table_exists->table_exists( false ) ) {
456 465 // Create backup table
457 - $wpdb->query(
466 + $wpdb->query( // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- plugin table
458 467 $wpdb->prepare(
459 - 'create table `%1s` as select * from `%1s`', // phpcs:ignore WordPress.DB.PreparedSQLPlaceholders
468 + 'create table `%1s` as select * from `%1s`', // phpcs:ignore WordPress.DB.PreparedSQLPlaceholders, WordPress.DB.DirectDatabaseQuery.SchemaChange
460 469 array(
461 470 WPDA::remove_backticks( $wpdb->prefix . $key . $bck_postfix ),
462 471 WPDA::remove_backticks( $table_name ),
463 472 )