Skip to content
planv edited this page Mar 4, 2020 · 5 revisions

WP-CLI Support

WP-Stateless works with the WP-CLI command wp stateless for upgrading postmeta and sync media.

It uses subcommands under the wp stateless command. The syntax for the subcommands is as follows.

wp stateless upgrade meta <uri> [<type>] [--start=<val>] [--limit=<val>] [--end=<val>] [--batch=<val>] [--batches=<val>] [--b] [--log] [--o]

wp stateless sync images <uri> [<type>] [--start=<val>] [--limit=<val>] [--end=<val>] [--batch=<val>] [--batches=<val>] [--b] [--log] [--o] [--force] [--continue] [--fix] [--order]

wp stateless sync files <uri> [<type>] [--start=<val>] [--limit=<val>] [--end=<val>] [--batch=<val>] [--batches=<val>] [--b] [--log] [--o] [--force] [--continue] [--fix] [--order]

Subcommand upgrade.

Uses for upgrade DB after updating plugin.

Subcommand sync.

Uses for sync attachments with GCS. May be run for images (mode images) and non-images (mode files) attachments. By default command sync only non-synchronized attachments. For force sync all media should be used option --force. Limit by default set to 100.

Optional arguments

Argument Description
--start Indent (sql OFFSET). It's ignored on batches
--limit Limit per query (sql LIMIT)
--end Where ( on which row ) we should stop script. It's ignored on batches
--batch Number of Batch. Default is 1
--batches General amount of batches
--b Runs command using batches till it's done. Other parameters will be ignored. There are 10 batches by default. Batch is external command process
--log Show more information in command line
--o Process includes database optimization and transient removing

Optional arguments which uses only for subcommand sync

Argument Description
--force Force sync all images or files
--continue Continue the last process
--fix Try to fix previously failed items
--order Order (sql ORDER BY). May be ASC or DESC. By default is DESC

EXAMPLES

wp stateless sync images --url=example.com --b

Run process looping 10 batches. Every batch is external command 'wp stateless sync images --url=example.com --batch= --batches=10'

wp stateless sync images --url=example.com --b --batches=100

Run process looping 100 batches.

wp stateless sync images --url=example.com --b --batches=10 --batch=2

Run second batch from 10 batches manually.

wp stateless sync images --url=example.com --log

Run default process showing additional information in command line.

wp stateless sync images --url=example.com --end=3000 --limit=50

Run process from 1 to 3000 row. Splits process by limiting queries to 50 rows. So, the current example does 60 queries ( 3000 / 50 = 60 ).

wp stateless sync images --url=example.com --start=777 --end=3000 --o

Run process from 777 to 3000 row. Also does database optimization and removes transient in the end.

wp stateless sync images --url=example.com --log

Run process with additional logs in command line.

wp stateless sync images --url=example.com --force

Run process for all existing images, including already synchronized images.

wp stateless sync images --url=example.com --continue --order=ASC

Run process from last synchronized image, items will be ordered by ASC.

wp stateless sync images --url=example.com --fix

Run process only for previously failed items and trying to fix its.

Clone this wiki locally