@@ -192,11 +192,13 @@ class Search_Replace_Command extends WP_CLI_Command {
192192 *
193193 * [--skip-columns=<columns>]
194194 * : Do not perform the replacement on specific columns. Use commas to
195- * specify multiple columns.
195+ * specify multiple columns. Table-qualified column names ("table.column")
196+ * are supported to apply the skip to a specific table only.
196197 *
197198 * [--include-columns=<columns>]
198199 * : Perform the replacement on specific columns. Use commas to
199- * specify multiple columns.
200+ * specify multiple columns. Table-qualified column names ("table.column")
201+ * are supported to apply the inclusion to a specific table only.
200202 *
201203 * [--precise]
202204 * : Force the use of PHP (instead of SQL) for all columns. By default, the command
@@ -530,11 +532,11 @@ public function __invoke( $args, $assoc_args ) {
530532 }
531533
532534 foreach ( $ columns as $ col ) {
533- if ( ! empty ( $ this ->include_columns ) && ! in_array ( $ col , $ this ->include_columns , true ) ) {
535+ if ( ! empty ( $ this ->include_columns ) && ! in_array ( $ col , $ this ->include_columns , true ) && ! in_array ( $ table . ' . ' . $ col , $ this -> include_columns , true ) ) {
534536 continue ;
535537 }
536538
537- if ( in_array ( $ col , $ this ->skip_columns , true ) ) {
539+ if ( in_array ( $ col , $ this ->skip_columns , true ) || in_array ( $ table . ' . ' . $ col , $ this -> skip_columns , true ) ) {
538540 continue ;
539541 }
540542
@@ -633,7 +635,12 @@ private function php_export_table( $table, $old, $new ) {
633635 $ row_fields = array ();
634636 foreach ( $ all_columns as $ col ) {
635637 $ value = $ row ->$ col ;
636- if ( $ value && ! in_array ( $ col , $ primary_keys , true ) && ! in_array ( $ col , $ this ->skip_columns , true ) ) {
638+ if ( $ value
639+ && ! in_array ( $ col , $ primary_keys , true )
640+ && ! in_array ( $ col , $ this ->skip_columns , true )
641+ && ! in_array ( $ table . '. ' . $ col , $ this ->skip_columns , true )
642+ && ( empty ( $ this ->include_columns ) || in_array ( $ col , $ this ->include_columns , true ) || in_array ( $ table . '. ' . $ col , $ this ->include_columns , true ) )
643+ ) {
637644 $ new_value = $ replacer ->run ( $ value );
638645 if ( $ new_value !== $ value ) {
639646 ++$ col_counts [ $ col ];
0 commit comments