Specify Key value when Search and Replace in Serialized Data

Open
#105 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
wordpress
Domain
cli, database

Research direction

Start with the wp search-replace entry point and review how meta_key and meta_value are processed for serialized data. Done means allowing replacement to be limited to rows whose meta_key matches amazonS3_info, while preserving correct serialized-data updates.

Written by the indexing model from the issue text.

Description

command:search-replace

I came across the scenario of moving my S3 bucket and while doing that also changed the path.

I upload an image, It is sent to Kraken.io, and Uploaded to S3 using Media Offload.

I made a copy locally of the database and ran wp search-replace 'old-bucket 'new-bucket. To my joy, the serialized string was also updated.

My next task was to update the media path. Previously it would have been old-bucket/year/month

Now it would be new-bucket/media/year/month

If I were to search and replace based off of /2015 I am going to affect the _wp_attached_file and _wp_attachment_metadata

Is it possible to search inside of two columns where one column value is equal to something else?

Like look in meta_value where meta_key == amazonS3_info?

Dominant language
Gherkin
Stars
61
Forks
47
Avg merge
8m
Merged PRs (30d)
1

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from wp-cli/search-replace-command

All issues in wp-cli/search-replace-command

Similar issues

More CLI issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.