wp-cli / search-replace-command

Searches/replaces strings in the database.
MIT License
57 stars 45 forks source link

Search-replace command do not work properly #106

Closed betagoo closed 1 year ago

betagoo commented 5 years ago

I think, the search-replace command do not work properly.

Post content code contains: some text <a href="[page_url 363]" class="btn">anchor text</a> some text

This wp-cli command found only 14 posts: search-replace '<a\s+href="\[page_url\s+363\]"([^>]+)>([^<]+)<\/a>' 'ReplaceText' wp_posts --regex --allow-root --regex-flags='i' --regex-delimiter='/' --log --dry-run

Should find 73 posts.

If I make get_posts and execute preg_replace function on post content, the php script found every occurences into 73 posts (there is one occurence in one post).

Pattern, delimiters and flags are the same.

marksabbath commented 4 years ago

Hey @betagoo !

I'd like to run some tests to try to replicate this issue. Could you please confirm if the text that changes is only the number?

marksabbath commented 4 years ago

Also, sharing the code you've run that found 73 entries and the database would be very helpful :)