Happy 2016! I thought you might enjoy a new WP-CLI release before I dive into the RESTful CLI project.
wp cli update to install v0.22.0, representing 137 resolved issues and pull requests. Here’s what’s new.
search-replace for love and profit
Last month, Pantheon generously sponsored 15 hours of my time to address some of the long-standing bugs in the backlog, and make a few substantial enhancements too.
Let’s start with the good stuff:
- Performance boost! Instead of running a MYSQL LIKE statement every 1000 rows, WP-CLI now just runs it once [#2304]. On a post meta table of ~3.5 million rows where 75,610 rows were affected, this change improved execution time from 734.926s to 225.509s (3.3x faster).
- Use the
--export=<filename>argument to create a SQL file of your transformed data, instead of making updates to the database [#2254]. This is a helpful feature when you want to prepare a database for a new environment without having to import and then run search-replace.
- Wildcards can be used in table names [#2233]. search-replace against just meta tables with
wp search-replace <old-string> <new-string> '*meta*'. Note: the pattern needs to be quoted, as
*is a special character in Bash.
I also landed a number of search-replace bug fixes and minor enhancements:
- Recurses objects by default when replacing inside of serialized data [#2222]. Among other things, this ensures theme mods are transformed as expected. You can disable the behavior with
--no-recurse-objects. But, if you do disable the behavior, I’d like to hear from you. I think this is an unnecessary option we could remove at a later date.
- Properly escapes quotes used in search or replace strings [#2230].
- Lets users know to flush their persistent object cache after a search-replace procedure is performed [#2236].
- Bails early when the replacement string is the same as the search string [#2235].
- Indicates execution time when running search/replace with
- Prevents unnecessary calls to
$wpdb->update()when there are no replacements to be made [#2245].
- Drops unnecessary
REGEXPquery when in regex mode [#2305].
Changes to supported versions
WP-CLI’s minimum supported WordPress version is now 3.7 [#2261].
We also officially support PHP 7 [#2330].
Everything else in v0.22.0
wp scaffold (plugin|plugin-tests):
- Makes Travis less noisy by only sending email notifications on the initial build failure for a branch [#2194].
- Plugin header follows WordPress’ PHPDoc standards [#2197].
.distextension to PHPUnit config file to permit overriding with a local config file [#2247]
readme.txtto find WordPress versions to use as Travis tested versions [#2255].
- Includes a default
New flags for existing commands:
wp core update --minorto only perform minor updates [#2256].
wp (post|comment|user) meta delete <id> --allto delete all meta values on a given object [#2265].
wp core update-db --dry-runto see whether a database needs an upgrade [#2293].
wp media regenerate --only-missingfor faster performance on sites with lots of images where only a small number are missing sizes [#2292].
wp cron event run --allto execute all registered cron events [#2323].
wp site empty --uploadsto empty a site and delete its uploads directory too [#2339].
wp core install --skip-emailto install without email notifications [#2345].
wp transient (get|set|delete) --networkto manage site transients [#2351].
wp_version_compare()when comparing WordPress versions [#2237]. SVN and Git tags include
- Defers to the
$PAGERenvironment variable when set [#2264].
- Introduces a
composer.lockfile to the project, to fix dependencies to specific hashes [#2280].
- Magically globalizes any new variables defined in wp-config.php, as they’re expected to be global [#2318].
- If a
--require=<file>is missing, specifies the context of where the missing file is referenced for easier debugging [#2336].
mustangostang/spycinstead of bundling our own copy [#2350]. The
Spycclass is still available in the global namespace.
WP_CLI\Utils\get_temp_dir()for safer temp directories [#2353].
Improvements to other commands:
not_foundlabel when scaffolding a custom taxonomy [#2196].
- Permits installing remote plugin files without
.zipin filename [#2193].
- Warns when adding a user as a super admin when the user is already a super admin [#2202].
wp import, so
--quietflag is respected [#2234].
- Adds support to
wp db tablesfor wildcard tables (e.g.
- Improves error message when installing a plugin or theme and the resource isn’t found [#2253,#2267].
- Supports custom
wp exportfilename formats with
- Assumes db errors during
wp installto be installation failures, and reports accordingly [#2337].
- Exposes plugin header details at runtime for
wp scaffold plugin[#2338].
wp scaffold package-tests[#2342].
Bug fixes across the board:
helprun early when WP is detected, but not installed (e.g.
wp core config --help) [#2190]. Bug was introduced in v0.20.0.
- When scaffolding a child theme, creates a safe version of the parent theme slug for the child enqueue function [#2203]. Previously, if the parent slug included dashes, an invalid enqueue function would be scaffolded.
- Suppresses error notices when looking for
open_basediris in effect [#2211].
- Fixes error notice in
all_itemslabel in custom post type scaffolding [#2213].
install-package-tests.shactually downloads the nightly WP-CLI Phar build, and not a redirect [#2214].
- Sets the
1when installing multisite [#2238]. This mirrors core’s behavior on new installs.
- Provides a more helpful message when image regeneration fails [#2239].
- Properly updates menu sub-item parent when parent is deleted [#2262].
- Stops prefixing rewrite rules with
wp rewrite structure[#2279].
- Fixes typo in
wp transient setsynopsis [#2282].
wp core verify-checksumsfor non-US English locales [#2287]. Bug was introduced in v0.21.0.
- Switches to the readline library, when available, for better support of arrow keys using
WP_CLI\Formatterproperly checks for null values on objects [#2322].
wp media import, uses host instead of scheme to determine whether a file is remote or local, for Windows compatibility [#2324].
- Ensures updating a plugin with an invalid
--version=<version>specified doesn’t delete the plugin [#2346].
Contributors to this release: 2ndkauboy, coreyworrell, danielbachhuber, davidleach, duncanjbrown, ernilambar, fjarrett, gilbitron, greg-1-anderson, iandunn, jjeaton, modelm, rodrigoprimo, ryanshoover, stevector, szepeviktor, tristanpenman, x1024
You can browse the full list of resolved issues on GitHub.