@@ -184,11 +184,13 @@ class Search_Replace_Command extends WP_CLI_Command {
184184 *
185185 * [--skip-columns=<columns>]
186186 * : Do not perform the replacement on specific columns. Use commas to
187- * specify multiple columns.
187+ * specify multiple columns. Table-qualified column names ("table.column")
188+ * are supported to apply the skip to a specific table only.
188189 *
189190 * [--include-columns=<columns>]
190191 * : Perform the replacement on specific columns. Use commas to
191- * specify multiple columns.
192+ * specify multiple columns. Table-qualified column names ("table.column")
193+ * are supported to apply the inclusion to a specific table only.
192194 *
193195 * [--precise]
194196 * : Force the use of PHP (instead of SQL) for all columns. By default, the command
@@ -510,11 +512,11 @@ public function __invoke( $args, $assoc_args ) {
510512 }
511513
512514 foreach ( $ columns as $ col ) {
513- if ( ! empty ( $ this ->include_columns ) && ! in_array ( $ col , $ this ->include_columns , true ) ) {
515+ if ( ! empty ( $ this ->include_columns ) && ! in_array ( $ col , $ this ->include_columns , true ) && ! in_array ( $ table . ' . ' . $ col , $ this -> include_columns , true ) ) {
514516 continue ;
515517 }
516518
517- if ( in_array ( $ col , $ this ->skip_columns , true ) ) {
519+ if ( in_array ( $ col , $ this ->skip_columns , true ) || in_array ( $ table . ' . ' . $ col , $ this -> skip_columns , true ) ) {
518520 continue ;
519521 }
520522
@@ -613,7 +615,11 @@ private function php_export_table( $table, $old, $new ) {
613615 $ row_fields = array ();
614616 foreach ( $ all_columns as $ col ) {
615617 $ value = $ row ->$ col ;
616- if ( $ value && ! in_array ( $ col , $ primary_keys , true ) && ! in_array ( $ col , $ this ->skip_columns , true ) ) {
618+ if ( ! empty ( $ this ->include_columns ) && ! in_array ( $ col , $ this ->include_columns , true ) && ! in_array ( $ table . '. ' . $ col , $ this ->include_columns , true ) ) {
619+ $ row_fields [ $ col ] = $ value ;
620+ continue ;
621+ }
622+ if ( $ value && ! in_array ( $ col , $ primary_keys , true ) && ! in_array ( $ col , $ this ->skip_columns , true ) && ! in_array ( $ table . '. ' . $ col , $ this ->skip_columns , true ) ) {
617623 $ new_value = $ replacer ->run ( $ value );
618624 if ( $ new_value !== $ value ) {
619625 ++$ col_counts [ $ col ];
0 commit comments