Skip to content

Commit 3e0e5a0

Browse files
Copilotswissspidy
andcommitted
Add WP_CLI::log message before progress bar to show processing status
Added WP_CLI::log() call to output "Updating table.column (X rows)" message before creating progress bar. This ensures users see feedback even if the progress bar doesn't display properly, and provides clear indication of what's being processed. Also reverted test back to checking STDOUT as requested. Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
1 parent 46ba4ed commit 3e0e5a0

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

features/search-replace.feature

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1400,7 +1400,7 @@ Feature: Do global search/replace
14001400
And I run `wp option set test_url 'Visit http://example.com for more'`
14011401

14021402
When I run `wp search-replace http://example.com http://example.org --precise`
1403-
Then STDERR should contain:
1403+
Then STDOUT should contain:
14041404
"""
14051405
Updating
14061406
"""
@@ -1415,7 +1415,7 @@ Feature: Do global search/replace
14151415
"""
14161416
Checking:
14171417
"""
1418-
And STDERR should not contain:
1418+
And STDOUT should not contain:
14191419
"""
14201420
Updating
14211421
"""

src/Search_Replace_Command.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,8 @@ private function php_export_table( $table, $old, $new ) {
565565
// phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- escaped through self::esc_sql_ident
566566
$total_rows = $wpdb->get_var( "SELECT COUNT(*) FROM {$table_sql}" );
567567
if ( $total_rows > 0 ) {
568-
$progress = \WP_CLI\Utils\make_progress_bar( sprintf( 'Exporting %s', $table ), $total_rows );
568+
WP_CLI::log( sprintf( 'Exporting %s (%d rows)', $table, $total_rows ) );
569+
$progress = \WP_CLI\Utils\make_progress_bar( sprintf( 'Progress' ), $total_rows );
569570
}
570571
}
571572

@@ -677,7 +678,8 @@ static function ( $key ) {
677678
// phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- escaped through self::esc_sql_ident
678679
$total_rows = $wpdb->get_var( "SELECT COUNT(*) FROM {$table_sql} {$where_key}" );
679680
if ( $total_rows > 0 ) {
680-
$progress = \WP_CLI\Utils\make_progress_bar( sprintf( 'Updating %s.%s', $table, $col ), $total_rows );
681+
WP_CLI::log( sprintf( 'Updating %s.%s (%d rows)', $table, $col, $total_rows ) );
682+
$progress = \WP_CLI\Utils\make_progress_bar( sprintf( 'Progress', $table, $col ), $total_rows );
681683
}
682684
}
683685

0 commit comments

Comments
 (0)