Limit search-replace in DB --wp_db_id="wp_posts:1234" (New command parameter)

Aperta
#142 5 commenti 2 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
35/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
wordpress
Ambito
cli, databases

Direzione di ricerca

Start at the wp search-replace command entry point and inspect how it selects database tables and records. Add support for the table:id form, including the documented WordPress ID mappings and optional comma-separated IDs. Done means a dry run changes only the requested records while existing unrestricted searches continue to work.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

command:search-replace

I often want to apply the wp search-replace command to only one single database record. (Sometimes for testing, sometimes, because I know, that I only have to replace data in one post.) Most often it's a single post ID in wp_posts.

Current situation:

The following command makes a dry run to replace "each and every" match of class="old". It's not possible to limit it to one id of a specific WordPress table.

wp search-replace 'class="old"' 'class="new"' --log --dry-run

Feature request

Add a new command parameter (--wp_db_id="") to set the database table name and the id of a record in order to limit the search-replace command.

--wp_db_id="wp_posts:123"

The correct id field for each WordPress entity is mapped automatically internally. See example below.

Mapping example

  • --wp_db_id="wp_posts:123" (translates internally into wp_posts.ID=123)
  • --wp_db_id="wp_options:789" (translates into wp_options.option_id=789)
  • --wp_db_id="wp_terms:1823" (translates into wp_terms.term_id=1823)

--wp_db_id="{WordPress table name}:{id}"

New command demo

The new command looks like this. It only replaces the record with wp_options.option_id=789.

wp search-replace 'class="old"' 'class="new"' --wp_db_id="wp_options:789" --log --dry-run

Exra feature: Comma separated list of ids

May it's also possible, to add more than one id.

--wp_db_id="wp_terms:1823,1233,2399"

Lingua principale
Gherkin
Stelle
61
Fork
47
Merge medio
8m
PR unite (30g)
1

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di wp-cli/search-replace-command

Tutte le issue di wp-cli/search-replace-command

Issue simili

Altre issue su CLI

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.