From: scribu Date: Mon, 23 Dec 2013 15:24:10 +0000 (+0200) Subject: don't list all invalid attachment IDs X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=e84a830a71433ff5a46723d648d6f844919d9189;p=wvm%2Fwvm.git don't list all invalid attachment IDs it gets too long when using `seq` --- diff --git a/php/commands/media.php b/php/commands/media.php index 97393e41..6faff8ed 100644 --- a/php/commands/media.php +++ b/php/commands/media.php @@ -44,19 +44,15 @@ class Media_Command extends WP_CLI_Command { $images = new WP_Query( $query_args ); - if ( $images->post_count == 0 ) { - //No images, so all keys in $args are not found within WP - WP_CLI::error( $this->_not_found_message( $args ) ); - } $count = $images->post_count; - WP_CLI::log( sprintf( 'Found %1$d %2$s to regenerate.', $count, ngettext('image', 'images', $count) ) ); - - $not_found = array_diff( $args, $images->posts ); - if( !empty($not_found) ) { - WP_CLI::warning( $this->_not_found_message( $not_found ) ); + if ( !$count ) { + WP_CLI::log( 'No images found.' ); + return; } + WP_CLI::log( sprintf( 'Found %1$d %2$s to regenerate.', $count, ngettext('image', 'images', $count) ) ); + foreach ( $images->posts as $id ) { $this->_process_regeneration( $id ); } @@ -244,17 +240,6 @@ class Media_Command extends WP_CLI_Command { unlink( $intermediate_path ); } } - - private function _not_found_message( $not_found_ids ){ - $count = count( $not_found_ids ); - - return vsprintf( 'Unable to find the %1$s (%2$s). Are you sure %3$s %4$s?', array( - ngettext('image', 'images', $count), - implode(", ", $not_found_ids), - ngettext('it', 'they', $count), - ngettext('exists', 'exist', $count), - ) ); - } } WP_CLI::add_command( 'media', 'Media_Command' );