1

I will be using this command with WP-CLI to batch change about 1,000 URLs.

while IFS=, read orig new; do wp --dry-run --skip-themes --skip-plugins search-replace "$orig" "$new" wp_posts --include-columns=post_content --verbose; done < example.csv

The contents of the .csv is two columns with the old and new strings:

https://www.oldurl1 https://www.newurl1 
https://www.oldurl2 https://www.newurl2
https://www.oldurl3 https://www.newurl3
etc...

The URLs are stored in an ACF custom field. Is this going to cause any serialisation issues?

1
  • note that while WP CLI is on topic, ACF and other 3rd party plugins are not and are outside the scope of this stack, this isn't a place to get help with ACF
    – Tom J Nowell
    Commented Apr 6, 2023 at 10:10

1 Answer 1

3

No because you're running the command on the posts table, and only on the content column, but ACF fields aka post meta are stored in the post meta table, not the content column of the posts table so no search replacing is occurring.

You can tell WP CLI to perform the search replace with PHP to avoid PHP serialisation issues using --precise as specified in the official documentation:

https://developer.wordpress.org/cli/commands/search-replace/

Note that while this might avoid PHP serialisation/deserialisation problems, it's not a guarantee that ACF will behave itself, you would need to ask in an ACF community or try it out to know for certain ( 3rd party plugin questions are offtopic here )

2
  • thanks, I did ask and you are right about postmeta table. The URLs are stored in a text field so there won't be any serialisation issues.
    – JoaMika
    Commented Apr 7, 2023 at 11:29
  • I mention asking because I've encountered situations in the past were hashed URLs are stored, which means they're missed by a search replace, likewise even singular fields can sometimes be serialised. Take a backup before you do the search replace and try it out
    – Tom J Nowell
    Commented Apr 7, 2023 at 14:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.