| @@ -133,19 +133,19 @@ | ||
| 133 | 133 | |
| 134 | 134 | $suppress = $wpdb->suppress_errors( true ); |
| 135 | 135 | |
| 136 | 136 | // Remove foreign key constraints on app tables |
| 137 | - $wpdb->query( | |
| 138 | - "ALTER TABLE {$wpdb->prefix}wpda_app_apps DROP FOREIGN KEY `wp_wpda_app_apps_ibfk_1`" | |
| 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 | 139 | ); |
| 140 | - $wpdb->query( | |
| 141 | - "ALTER TABLE {$wpdb->prefix}wpda_app_apps DROP FOREIGN KEY `wp_wpda_app_apps_ibfk_2`" | |
| 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 | 142 | ); |
| 143 | - $wpdb->query( | |
| 144 | - "AlTER TABLE {$wpdb->prefix}wpda_app_container DROP FOREIGN KEY `wp_wpda_app_container_ibfk_1`" | |
| 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 | 145 | ); |
| 146 | 146 | |
| 147 | - $bck_postfix = WPDA_Restore_Repository::BACKUP_TABLE_EXTENSION . date( 'YmdHis' ); | |
| 147 | + $bck_postfix = WPDA_Restore_Repository::BACKUP_TABLE_EXTENSION . gmdate( 'YmdHis' ); | |
| 148 | 148 | foreach ( static::CREATE_TABLE as $key => $value ) { |
| 149 | 149 | $table_name = $wpdb->prefix . $key; |
| 150 | 150 | |
| 151 | 151 | // Check if table exists |
| @@ -157,11 +157,11 @@ | ||
| 157 | 157 | |
| 158 | 158 | if ( $table_check ) { |
| 159 | 159 | // Create backup table |
| 160 | 160 | $bck_table_name = $wpdb->prefix . $key . $bck_postfix; |
| 161 | - $wpdb->query( | |
| 161 | + $wpdb->query( // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- plugin table | |
| 162 | 162 | $wpdb->prepare( |
| 163 | - '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 | |
| 164 | 164 | array( |
| 165 | 165 | WPDA::remove_backticks( $bck_table_name ), |
| 166 | 166 | WPDA::remove_backticks( $table_name ), |
| 167 | 167 | ) |
| @@ -172,9 +172,9 @@ | ||
| 172 | 172 | if ( $table_check ) { |
| 173 | 173 | // Create temporary table to check for changes |
| 174 | 174 | if ( $this->run_script( $value[0], '_new' ) ) { |
| 175 | 175 | // Check if table structure was changed |
| 176 | - $table_diff = $wpdb->get_row( | |
| 176 | + $table_diff = $wpdb->get_row( // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- plugin table | |
| 177 | 177 | $wpdb->prepare( |
| 178 | 178 | 'select column_name,ordinal_position,data_type,column_type from ( |
| 179 | 179 | select column_name, ordinal_position, data_type, column_type, count(1) rowcount |
| 180 | 180 | from information_schema.columns |
| @@ -201,9 +201,9 @@ | ||
| 201 | 201 | $this->run_script( $sql_file ); |
| 202 | 202 | } |
| 203 | 203 | |
| 204 | 204 | // Get columns matching old and new repository table columns to restore as many values as possible |
| 205 | - $same_cols = $wpdb->get_results( | |
| 205 | + $same_cols = $wpdb->get_results( // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- plugin table | |
| 206 | 206 | $wpdb->prepare( |
| 207 | 207 | 'select c1.column_name as column_name |
| 208 | 208 | from information_schema.columns c1 |
| 209 | 209 | where c1.table_schema = %s |
| @@ -228,9 +228,9 @@ | ||
| 228 | 228 | foreach ( $same_cols as $same_col ) { |
| 229 | 229 | $selected_columns .= $same_col['column_name'] . ','; |
| 230 | 230 | } |
| 231 | 231 | $selected_columns = substr( $selected_columns, 0, strlen( $selected_columns ) - 1 ); |
| 232 | - $wpdb->query( | |
| 232 | + $wpdb->query( // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- plugin table | |
| 233 | 233 | $wpdb->prepare( |
| 234 | 234 | 'insert into `%1s` (%1s) select %1s from `%1s`', // phpcs:ignore WordPress.DB.PreparedSQLPlaceholders |
| 235 | 235 | array( |
| 236 | 236 | WPDA::remove_backticks( $table_name ), |
| @@ -266,9 +266,9 @@ | ||
| 266 | 266 | $backup_tables_kept = WPDA::get_option( WPDA::OPTION_MR_BACKUP_TABLES_KEPT ); |
| 267 | 267 | $base_table_name = WPDA_Publisher_Model::get_base_table_name() . WPDA_Restore_Repository::BACKUP_TABLE_EXTENSION; |
| 268 | 268 | |
| 269 | 269 | global $wpdb; |
| 270 | - $rows = $wpdb->get_results( | |
| 270 | + $rows = $wpdb->get_results( // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- plugin table | |
| 271 | 271 | $wpdb->prepare( |
| 272 | 272 | ' |
| 273 | 273 | select table_name as table_name |
| 274 | 274 | from information_schema.tables |
| @@ -283,9 +283,9 @@ | ||
| 283 | 283 | ), |
| 284 | 284 | 'ARRAY_A' |
| 285 | 285 | ); |
| 286 | 286 | |
| 287 | - 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 | |
| 288 | 288 | $backup_date = substr( $rows[ $i ]['table_name'], strlen( $base_table_name ) ); |
| 289 | 289 | $this->remove_backup( $backup_date ); |
| 290 | 290 | } |
| 291 | 291 | } |
| @@ -297,11 +297,11 @@ | ||
| 297 | 297 | |
| 298 | 298 | $suppress = $wpdb->suppress_errors( true ); |
| 299 | 299 | $extension = WPDA_Restore_Repository::BACKUP_TABLE_EXTENSION; |
| 300 | 300 | foreach ( self::CREATE_TABLE as $key => $value ) { |
| 301 | - $wpdb->query( | |
| 301 | + $wpdb->query( // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- plugin table | |
| 302 | 302 | $wpdb->prepare( |
| 303 | - 'drop table `%1s`', // phpcs:ignore WordPress.DB.PreparedSQLPlaceholders | |
| 303 | + 'drop table `%1s`', // phpcs:ignore WordPress.DB.PreparedSQLPlaceholders, WordPress.DB.DirectDatabaseQuery.SchemaChange | |
| 304 | 304 | array( |
| 305 | 305 | WPDA::remove_backticks( "{$wpdb->prefix}{$key}{$extension}{$backup_date_sanitized}" ), |
| 306 | 306 | ) |
| 307 | 307 | ) |
| @@ -316,28 +316,28 @@ | ||
| 316 | 316 | protected function cleanup() { |
| 317 | 317 | global $wpdb; |
| 318 | 318 | |
| 319 | 319 | // Remove previous data table list table settings |
| 320 | - $wpdb->query( | |
| 320 | + $wpdb->query( // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- plugin table | |
| 321 | 321 | "delete from {$wpdb->prefix}usermeta where meta_key like '%columnshidden%' and meta_key like '%wpda_publisher%'" |
| 322 | 322 | ); |
| 323 | 323 | |
| 324 | 324 | // Remove previous project page list table settings |
| 325 | - $wpdb->query( | |
| 325 | + $wpdb->query( // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- plugin table | |
| 326 | 326 | "delete from {$wpdb->prefix}usermeta where meta_key like '%columnshidden%' and meta_key like '%wpda_project%'" |
| 327 | 327 | ); |
| 328 | 328 | |
| 329 | 329 | // Allow column to contain null values |
| 330 | - $wpdb->query( | |
| 331 | - "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 | |
| 332 | 332 | ); |
| 333 | 333 | |
| 334 | 334 | // Remove material sort icons from data tables |
| 335 | - $wpdb->query( | |
| 335 | + $wpdb->query( // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- plugin table | |
| 336 | 336 | "update {$wpdb->prefix}wpda_publisher set pub_sort_icons = 'default' where pub_sort_icons = 'plugin'" |
| 337 | 337 | ); |
| 338 | - $wpdb->query( | |
| 339 | - "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 | |
| 340 | 340 | ); |
| 341 | 341 | |
| 342 | 342 | // Remove plugin configuration settings: wrong values installed with 5.0.0 (needs to be reset on next deployment) |
| 343 | 343 | delete_option( 'wpda_plugin_navigation' ); |
| @@ -381,14 +381,14 @@ | ||
| 381 | 381 | * @since 2.0.11 |
| 382 | 382 | */ |
| 383 | 383 | public function run_script( $sql_file, $wpda_postfix = '' ) { |
| 384 | 384 | $sql_repository_file = $this->sql_repository_dir . $sql_file; |
| 385 | - $sql_repository_handle = fopen( $sql_repository_file, 'r' ); | |
| 385 | + $sql_repository_handle = fopen( $sql_repository_file, 'r' ); // phpcs:ignore | |
| 386 | 386 | |
| 387 | 387 | if ( $sql_repository_handle ) { |
| 388 | 388 | // Read file content and close handle. |
| 389 | - $sql_repository_file_content = fread( $sql_repository_handle, filesize( $sql_repository_file ) ); | |
| 390 | - 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 | |
| 391 | 391 | |
| 392 | 392 | global $wpdb; |
| 393 | 393 | |
| 394 | 394 | // Replace WP prefix and WPDA prefix. |
| @@ -397,9 +397,9 @@ | ||
| 397 | 397 | $sql_repository_file_content = str_replace( '{wpda_postfix}', $wpda_postfix, $sql_repository_file_content ); |
| 398 | 398 | $sql_repository_file_content = str_replace( '{wpda_collate}', $wpdb->get_charset_collate(), $sql_repository_file_content ); |
| 399 | 399 | |
| 400 | 400 | // Run script from admin/repository. |
| 401 | - return $wpdb->query( $sql_repository_file_content ); // phpcs:ignore WordPress.DB.PreparedSQL | |
| 401 | + return $wpdb->query( $sql_repository_file_content ); // phpcs:ignore -- plugin tables | |
| 402 | 402 | } |
| 403 | 403 | } |
| 404 | 404 | |
| 405 | 405 | |
| @@ -412,9 +412,9 @@ | ||
| 412 | 412 | if ( ! is_admin() ) { |
| 413 | 413 | return; |
| 414 | 414 | } |
| 415 | 415 | |
| 416 | - 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 | |
| 417 | 417 | // Turn off menu management not available message. |
| 418 | 418 | WPDA::set_option( WPDA::OPTION_WPDA_SETUP_ERROR, 'off' ); |
| 419 | 419 | } else { |
| 420 | 420 | if ( 'off' !== WPDA::get_option( WPDA::OPTION_WPDA_SETUP_ERROR ) ) { |
| @@ -439,9 +439,9 @@ | ||
| 439 | 439 | '<a href="?page=wpdataaccess&tab=repository">' . __( 'Recreate repository', 'wp-data-access' ) . '</a>' . |
| 440 | 440 | ' ' . |
| 441 | 441 | __( 'to to solve this problem.', 'wp-data-access' ) . |
| 442 | 442 | ' [' . |
| 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>' . | |
| 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 | |
| 444 | 444 | ']', |
| 445 | 445 | ) |
| 446 | 446 | ); |
| 447 | 447 | |
| @@ -453,9 +453,9 @@ | ||
| 453 | 453 | |
| 454 | 454 | public function create_new_backup() { |
| 455 | 455 | global $wpdb; |
| 456 | 456 | |
| 457 | - $bck_postfix = WPDA_Restore_Repository::BACKUP_TABLE_EXTENSION . date( 'YmdHis' ); | |
| 457 | + $bck_postfix = WPDA_Restore_Repository::BACKUP_TABLE_EXTENSION . gmdate( 'YmdHis' ); | |
| 458 | 458 | foreach ( static::CREATE_TABLE as $key => $value ) { |
| 459 | 459 | $table_name = $wpdb->prefix . $key; |
| 460 | 460 | |
| 461 | 461 | // Check if table exists |
| @@ -462,11 +462,11 @@ | ||
| 462 | 462 | $table_exists = new WPDA_Dictionary_Exist( $wpdb->dbname, $table_name ); |
| 463 | 463 | |
| 464 | 464 | if ( $table_exists->table_exists( false ) ) { |
| 465 | 465 | // Create backup table |
| 466 | - $wpdb->query( | |
| 466 | + $wpdb->query( // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- plugin table | |
| 467 | 467 | $wpdb->prepare( |
| 468 | - '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 | |
| 469 | 469 | array( |
| 470 | 470 | WPDA::remove_backticks( $wpdb->prefix . $key . $bck_postfix ), |
| 471 | 471 | WPDA::remove_backticks( $table_name ), |
| 472 | 472 | ) |