Skip to content

Conversation

@drzraf
Copy link

@drzraf drzraf commented Oct 17, 2025

Replacement callback & row-based filtering (include/exclude posts revisions)

  • Replacing revisions is confusing (total replacements count) and annoying
  • Specifying rows/columns/custom --where expression has been a long requested feature (for more than 8 years)
  • Extra flexibility regarding replacements (custom PHP callback) has also been requested multiple times

@drzraf drzraf requested a review from a team as a code owner October 17, 2025 03:17
@codecov
Copy link

codecov bot commented Oct 17, 2025

Codecov Report

❌ Patch coverage is 95.61404% with 5 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/WP_CLI/SearchReplacer.php 77.27% 5 Missing ⚠️

📢 Thoughts on this report? Let us know!

@swissspidy
Copy link
Member

swissspidy commented Oct 18, 2025

Thanks for your PR!

Would it be possible to split it up into 3 individual ones, one per new argument? That would make reviews much easier.

There could also be one .feature file per new argument for example. search-replace-new-options.feature doesn't really make sense (define new... what if we add even newer arguments two months from now 😄)

PS. Notice the lint failure

@drzraf
Copy link
Author

drzraf commented Oct 19, 2025

  • Splitting the *.features: sure. I just did in this later commit (+ phpcs)

  • But splitting logically the actual code changes seems over my forces.

  1. It would have been humanly impossible for me develop them separately and keep them in sync one with the other and all against upstream branch across these many years and actually use them (maintaining a combined branch).
  2. I think this was my last burst of motivation : if anything goes out of sync again, I'm too likely to just definitely give up

I understand it's a significant diff on core code, but: 175 insertions(+), 43 deletions(-) doesn't seem that much considering the amount of capabilities these new options brings to search-replace

  • I don't understand the phpstan error:
    php -r '$r["post"]["*"][] = "c"; print_r($r);' is valid.

  • Also, there at least one imperfection I'm aware of:

  • --where <table>:<col>:<cond> is actually adding <col> restrictions globally (not actually scoped to said table (reusing the logic of --include-columns). Moving the restriction more precisely, within the search and replace inner loops is probably doable, but would be even more complex (to write/assess and review).
    It's better left to a future improvement (and the current logic is not breaking anything anyway)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Filter by post types and post status in post table Pass current $col and $primary_keys down to the SearchReplacer

2 participants