@@ -321,8 +321,10 @@ public function __invoke( $args, $assoc_args ) {
321
321
322
322
if ( $ this ->export_handle ) {
323
323
fwrite ( $ this ->export_handle , "\nDROP TABLE IF EXISTS $ table_sql; \n" );
324
+
324
325
// phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- escaped through self::esc_sql_ident
325
326
$ row = $ wpdb ->get_row ( "SHOW CREATE TABLE $ table_sql " , ARRAY_N );
327
+
326
328
fwrite ( $ this ->export_handle , $ row [1 ] . "; \n" );
327
329
list ( $ table_report , $ total_rows ) = $ this ->php_export_table ( $ table , $ old , $ new );
328
330
if ( $ this ->report ) {
@@ -368,8 +370,10 @@ public function __invoke( $args, $assoc_args ) {
368
370
if ( ! $ php_only && ! $ this ->regex ) {
369
371
$ col_sql = self ::esc_sql_ident ( $ col );
370
372
$ wpdb ->last_error = '' ;
373
+
371
374
// phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- escaped through self::esc_sql_ident
372
- $ serial_row = $ wpdb ->get_row ( "SELECT * FROM $ table_sql WHERE $ col_sql REGEXP '^[aiO]:[1-9]' LIMIT 1 " );
375
+ $ serial_row = $ wpdb ->get_row ( "SELECT * FROM $ table_sql WHERE $ col_sql REGEXP '^[aiO]:[1-9]' LIMIT 1 " );
376
+
373
377
// When the regex triggers an error, we should fall back to PHP
374
378
if ( false !== strpos ( $ wpdb ->last_error , 'ERROR 1139 ' ) ) {
375
379
$ serial_row = true ;
@@ -522,8 +526,10 @@ private function php_handle_col( $col, $primary_keys, $table, $old, $new ) {
522
526
$ col_sql = self ::esc_sql_ident ( $ col );
523
527
$ where = $ this ->regex ? '' : " WHERE $ col_sql " . $ wpdb ->prepare ( ' LIKE BINARY %s ' , '% ' . self ::esc_like ( $ old ) . '% ' );
524
528
$ primary_keys_sql = implode ( ', ' , self ::esc_sql_ident ( $ primary_keys ) );
529
+
525
530
// phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- escaped through self::esc_sql_ident
526
- $ rows = $ wpdb ->get_results ( "SELECT {$ primary_keys_sql } FROM {$ table_sql } {$ where }" );
531
+ $ rows = $ wpdb ->get_results ( "SELECT {$ primary_keys_sql } FROM {$ table_sql } {$ where }" );
532
+
527
533
foreach ( $ rows as $ keys ) {
528
534
$ where_sql = '' ;
529
535
foreach ( (array ) $ keys as $ k => $ v ) {
@@ -532,8 +538,10 @@ private function php_handle_col( $col, $primary_keys, $table, $old, $new ) {
532
538
}
533
539
$ where_sql .= self ::esc_sql_ident ( $ k ) . ' = ' . self ::esc_sql_value ( $ v );
534
540
}
541
+
535
542
// phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- escaped through self::esc_sql_ident
536
543
$ col_value = $ wpdb ->get_var ( "SELECT {$ col_sql } FROM {$ table_sql } WHERE {$ where_sql }" );
544
+
537
545
if ( '' === $ col_value ) {
538
546
continue ;
539
547
}
@@ -648,8 +656,10 @@ private static function get_columns( $table ) {
648
656
$ text_columns = array ();
649
657
$ all_columns = array ();
650
658
$ suppress_errors = $ wpdb ->suppress_errors ();
659
+
651
660
// phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- escaped through self::esc_sql_ident
652
- $ results = $ wpdb ->get_results ( "DESCRIBE $ table_sql " );
661
+ $ results = $ wpdb ->get_results ( "DESCRIBE $ table_sql " );
662
+
653
663
if ( ! empty ( $ results ) ) {
654
664
foreach ( $ results as $ col ) {
655
665
if ( 'PRI ' === $ col ->Key ) {
@@ -791,6 +801,7 @@ private function log_sql_diff( $col, $primary_keys, $table, $old, $new ) {
791
801
792
802
// phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- escaped through self::esc_sql_ident
793
803
$ results = $ wpdb ->get_results ( $ wpdb ->prepare ( "SELECT {$ primary_keys_sql }{$ col_sql } FROM {$ table_sql } WHERE {$ col_sql } LIKE BINARY %s " , '% ' . self ::esc_like ( $ old ) . '% ' ), ARRAY_N );
804
+
794
805
if ( empty ( $ results ) ) {
795
806
return 0 ;
796
807
}
0 commit comments