Add progress bar for search-replace operations#206
Draft
Conversation
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add progress bar for search-replace command
Add progress bar for search-replace operations
Nov 10, 2025
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
This comment was marked as resolved.
This comment was marked as resolved.
Fixes logging test by suppressing progress bar whenever logging is enabled (not just when logging to STDOUT), as the progress bar output can interfere with clean log output. Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
Modified the "Progress bar shows when not in verbose mode" test to generate posts with content containing http://example.com. This ensures the progress bar has matching rows to process and display when using the --precise flag. Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
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>
This comment was marked as resolved.
This comment was marked as resolved.
Copilot
AI
changed the title
Add progress bar for search-replace operations
Add progress feedback for search-replace operations
Nov 14, 2025
This comment was marked as resolved.
This comment was marked as resolved.
Fixed sprintf format strings for make_progress_bar() calls. Changed from 'Progress' (which ignored table/col parameters) to 'Processing table.column' for regular processing and 'Processing table' for exports. This ensures the progress bar displays with meaningful labels. Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
Moved progress bar setup from before the while loop to inside the loop on first iteration. This ensures the progress bar is created when rows are actually fetched, even if the initial COUNT query returns 0. Addresses issue where COUNT might return 0 but the while loop still fetches rows to process. Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
This comment was marked as resolved.
This comment was marked as resolved.
swissspidy
reviewed
Mar 11, 2026
swissspidy
reviewed
Mar 11, 2026
Remove extra log messages before the progress bar ('Updating table.column (X rows)' and 'Exporting table (X rows)'). The progress bar label already includes the table and column names. Update Behat tests to check STDERR for 'Processing' (progress bar output) instead of STDOUT for 'Updating'.
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Copilot
AI
changed the title
Add progress feedback for search-replace operations
Add progress bar for search-replace operations
Mar 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Addresses lack of feedback during long-running search-replace operations on large tables (e.g., 1M+ rows in postmeta).
Description
Adds a progress bar using
\WP_CLI\Utils\make_progress_bar()for PHP-based row processing and table exports. The progress bar displays when:--preciseAutomatically suppressed when conflicting with existing output modes (
--verbose,--quiet,--format=count, logging enabled, or when exporting to STDOUT).Progress bar initialization is deferred until the first batch of rows is fetched from the database, ensuring it displays even in edge cases where a pre-check COUNT query might return 0.
Changes
should_show_progress_bar()helper checking output mode compatibilityphp_handle_col(): progress bar is initialized inside the while loop on the first iteration when rows are actually fetched, labelled "Processing table.column", ticks once per batch after processing each batch, and finishes on completionphp_export_table(): similar integration with a "Processing table" progress bar label--verbosewp option setto ensure the search string is present, so the progress bar is triggered with--preciseHow It Works
For regular search-replace operations (when
export_handleis false):php_handle_col()--precise, regex, or serialized data)For export operations (when
export_handleis a file handle):php_export_table()Example
Notes
Progress bar initialization is deferred until the first iteration of the while loop when rows are actually fetched. This handles edge cases where a pre-check COUNT query might return 0 but rows are still processed.
Progress bar advances by batch size (typically 1000 rows) rather than per individual row, providing accurate progress tracking aligned with database query batches.
Progress bar is suppressed whenever logging is enabled to ensure clean, parseable log output.
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.