OSDN Git Service

make sure the slug is always part of the warning
authorscribu <mail@scribu.net>
Sun, 25 Aug 2013 13:32:26 +0000 (16:32 +0300)
committerscribu <mail@scribu.net>
Sun, 25 Aug 2013 13:32:29 +0000 (16:32 +0300)
The standard plugin/theme upgrader strings don't contain the slug.

php/WP_CLI/CommandWithUpgrade.php
php/commands/plugin.php
php/commands/theme.php

index b8999b8..d1a327c 100644 (file)
@@ -101,6 +101,7 @@ abstract class CommandWithUpgrade extends \WP_CLI_Command {
 
                foreach ( $args as $slug ) {
                        $local_or_remote_zip_file = false;
+                       $result = false;
 
                        // Check if a URL to a remote zip file has been specified
                        $url_path = parse_url( $slug, PHP_URL_PATH );
@@ -119,24 +120,20 @@ abstract class CommandWithUpgrade extends \WP_CLI_Command {
 
                                if ( $file_upgrader->install( $local_or_remote_zip_file ) ) {
                                        $slug = $file_upgrader->result['destination_name'];
-
-                                       if ( isset( $assoc_args['activate'] ) ) {
-                                               \WP_CLI::log( "Activating '$slug'..." );
-                                               $this->activate( array( $slug ) );
-                                       }
+                                       $result = true;
                                }
                        } else {
                                // Assume a plugin/theme slug from the WordPress.org repository has been specified
                                $result = $this->install_from_repo( $slug, $assoc_args );
 
                                if ( is_wp_error( $result ) ) {
-                                       \WP_CLI::warning( $result );
+                                       \WP_CLI::warning( "$slug: " . $result->get_error_message() );
                                }
+                       }
 
-                               if ( $result && isset( $assoc_args['activate'] ) ) {
-                                       \WP_CLI::log( "Activating '$slug'..." );
-                                       $this->activate( array( $slug ) );
-                               }
+                       if ( $result && isset( $assoc_args['activate'] ) ) {
+                               \WP_CLI::log( "Activating '$slug'..." );
+                               $this->activate( array( $slug ) );
                        }
                }
        }
index 442c321..9611905 100644 (file)
@@ -269,7 +269,7 @@ class Plugin_Command extends \WP_CLI\CommandWithUpgrade {
 
                if ( !isset( $assoc_args['force'] ) && 'install' != $status['status'] ) {
                        // We know this will fail, so avoid a needless download of the package.
-                       return new WP_Error( 'already_installed', "$slug already installed." );
+                       return new WP_Error( 'already_installed', 'Plugin already installed.' );
                }
 
                WP_CLI::log( sprintf( 'Installing %s (%s)', $api->name, $api->version ) );
index ef1d8fc..c64ac16 100644 (file)
@@ -184,7 +184,7 @@ class Theme_Command extends \WP_CLI\CommandWithUpgrade {
 
                if ( !isset( $assoc_args['force'] ) && wp_get_theme( $slug )->exists() ) {
                        // We know this will fail, so avoid a needless download of the package.
-                       return new WP_Error( 'already_installed', "$slug already installed." );
+                       return new WP_Error( 'already_installed', 'Theme already installed.' );
                }
 
                WP_CLI::log( sprintf( 'Installing %s (%s)', $api->name, $api->version ) );