Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use new after_wp_config_load early invoke to run wp db * commands #57

Merged
merged 1 commit into from
Nov 6, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions src/DB_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
*
* # Execute a SQL query stored in a file.
* $ wp db query < debug.sql
*
* @when after_wp_config_load
*/
class DB_Command extends WP_CLI_Command {

Expand Down Expand Up @@ -469,6 +471,8 @@ public function import( $args, $assoc_args ) {
* # Export only tables for a single site
* $ wp db export --tables=$(wp db tables --url=sub.example.com --format=csv)
* Success: Exported to wordpress_dbase.sql
*
* @when after_wp_load
*/
public function tables( $args, $assoc_args ) {

Expand Down Expand Up @@ -568,12 +572,11 @@ public function tables( $args, $assoc_args ) {
*
* $ wp db size --size_format=mb
* 6
*
* @when after_wp_load
*/
public function size( $args, $assoc_args ) {

// Avoid a constant redefinition in wp-config.
@WP_CLI::get_runner()-> load_wordpress();

global $wpdb;

$format = WP_CLI\Utils\get_flag_value( $assoc_args, 'format' );
Expand Down Expand Up @@ -668,11 +671,10 @@ public function size( $args, $assoc_args ) {
*
* $ wp db prefix
* wp_
*
* @when after_wp_load
*/
public function prefix() {
// Avoid a constant redefinition in wp-config.
@WP_CLI::get_runner()->load_wordpress();

global $wpdb;

WP_CLI::log( $wpdb->prefix );
Expand Down Expand Up @@ -799,15 +801,13 @@ public function prefix() {
* ...
* Success: Found 99146 matches in 10.752s (10.559s searching). Searched 12 tables, 53 columns, 1358907 rows. 1 table skipped: wp_term_relationships.
*
* @when after_wp_load
*/
public function search( $args, $assoc_args ) {
global $wpdb;

$start_run_time = microtime( true );

// Avoid a constant redefinition in wp-config.
@WP_CLI::get_runner()->load_wordpress();

$search = array_shift( $args );

$before_context = \WP_CLI\Utils\get_flag_value( $assoc_args, 'before_context', 40 );
Expand Down