Skip to content

Clarify JSON-escaped search-replace behavior#233

Open
yusufhay wants to merge 1 commit intowp-cli:mainfrom
yusufhay:docs/json-escaped-search-replace
Open

Clarify JSON-escaped search-replace behavior#233
yusufhay wants to merge 1 commit intowp-cli:mainfrom
yusufhay:docs/json-escaped-search-replace

Conversation

@yusufhay
Copy link
Copy Markdown

@yusufhay yusufhay commented May 6, 2026

Summary

  • Document that non-regex search-replace also handles JSON-escaped strings like http://example.com
  • Add a short example for replacing URLs in plain text and JSON-escaped data

Testing

  • php -l src/Search_Replace_Command.php
  • composer validate --no-check-publish
  • git diff --check

Closes #45

@yusufhay yusufhay requested a review from a team as a code owner May 6, 2026 22:53
@github-actions github-actions Bot added command:search-replace Related to 'search-replace' command scope:documentation Related to documentation labels May 6, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 6, 2026

Hello! 👋

Thanks for opening this pull request! Please check out our contributing guidelines. We appreciate you taking the initiative to contribute to this project.

Contributing isn't limited to just code. We encourage you to contribute in the way that best fits your abilities, by writing tutorials, giving a demo at your local meetup, helping other users with their support questions, or revising our documentation.

Here are some useful Composer commands to get you started:

  • composer install: Install dependencies.
  • composer test: Run the full test suite.
  • composer phpcs: Check for code style violations.
  • composer phpcbf: Automatically fix code style violations.
  • composer phpunit: Run unit tests.
  • composer behat: Run behavior-driven tests.

To run a single Behat test, you can use the following command:

# Run all tests in a single file
composer behat features/some-feature.feature

# Run only a specific scenario (where 123 is the line number of the "Scenario:" title)
composer behat features/some-feature.feature:123

You can find a list of all available Behat steps in our handbook.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the documentation in README.md and src/Search_Replace_Command.php to clarify that the search-replace command handles JSON-escaped versions of search strings in non-regex mode. It also includes a new usage example for this functionality. I have no feedback to provide.

@yusufhay yusufhay force-pushed the docs/json-escaped-search-replace branch from 0652ae3 to 38fd251 Compare May 6, 2026 22:57
@codecov
Copy link
Copy Markdown

codecov Bot commented May 6, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the wp search-replace documentation to explicitly cover a common real-world case: URLs stored in JSON where / is escaped as \/, so non-regex search/replace will still find and replace those values.

Changes:

  • Document that non-regex mode also replaces the JSON-escaped form of the search string (e.g. http:\/\/...).
  • Add a short example showing URL replacement that applies to both plain text and JSON-escaped data.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/Search_Replace_Command.php Enhances command help text with JSON-escaped behavior notes and an additional usage example.
README.md Mirrors the updated help text in the generated README documentation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +142 to +144
* In non-regex mode, it also replaces JSON-escaped versions of the search
* string, such as `http:\/\/example.com` when searching for
* `http://example.com`.
Comment thread README.md
Comment on lines +284 to +286
* # Replace a URL in plain text and JSON-escaped data
* $ wp search-replace 'https://example.com' 'https://example.test'
*
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing about this example really says JSON, it doesn't provide any additional value over the very first example above.

Let's remove.

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

Labels

command:search-replace Related to 'search-replace' command scope:documentation Related to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Better communicate failure to search-replace JSON-serialized URLs

3 participants