Skip to content
Merged
Show file tree
Hide file tree
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
8 changes: 4 additions & 4 deletions features/media-regenerate.feature
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,11 @@ Feature: Regenerate WordPress attachments
"""
And STDOUT should contain:
"""
No thumbnail regeneration needed for "My second imported attachment"
1/2 No thumbnail regeneration needed for "My second imported attachment"
"""
And STDOUT should contain:
"""
Regenerated thumbnails for "My imported attachment"
2/2 Regenerated thumbnails for "My imported attachment"
"""
And STDOUT should contain:
"""
Expand Down Expand Up @@ -170,7 +170,7 @@ Feature: Regenerate WordPress attachments
"""
And STDOUT should contain:
"""
Regenerated thumbnails for "My imported attachment"
1/1 Regenerated thumbnails for "My imported attachment"
"""
And STDOUT should contain:
"""
Expand All @@ -185,7 +185,7 @@ Feature: Regenerate WordPress attachments
"""
And STDOUT should contain:
"""
No thumbnail regeneration needed for "My imported attachment"
1/1 No thumbnail regeneration needed for "My imported attachment"
"""
And STDOUT should contain:
"""
Expand Down
12 changes: 6 additions & 6 deletions php/commands/media.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ function regenerate( $args, $assoc_args = array() ) {
_n( 'image', 'images', $count ) ) );

$errored = false;
foreach ( $images->posts as $id ) {
if ( ! $this->_process_regeneration( $id, $skip_delete, $only_missing ) ) {
foreach ( $images->posts as $number => $id ) {
if ( ! $this->_process_regeneration( $id, $skip_delete, $only_missing, ( $number + 1 ) . '/' . $count ) ) {
$errored = true;
}
}
Expand Down Expand Up @@ -275,7 +275,7 @@ private function _make_copy( $path ) {
return $filename;
}

private function _process_regeneration( $id, $skip_delete = false, $only_missing = false ) {
private function _process_regeneration( $id, $skip_delete = false, $only_missing = false, $progress ) {

$fullsizepath = get_attached_file( $id );

Expand All @@ -299,16 +299,16 @@ private function _process_regeneration( $id, $skip_delete = false, $only_missing
}

if ( empty( $metadata ) ) {
WP_CLI::warning( "Couldn't regenerate thumbnails for $att_desc." );
WP_CLI::warning( "$progress Couldn't regenerate thumbnails for $att_desc." );
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does $progress ever remain empty?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... because, if it does, then we'd end up with an empty space before "Couldn't"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed the default argument value in 01bebd9, so I should never be empty now.

return false;
}

wp_update_attachment_metadata( $id, $metadata );

WP_CLI::log( "Regenerated thumbnails for $att_desc." );
WP_CLI::log( "$progress Regenerated thumbnails for $att_desc." );
return true;
} else {
WP_CLI::log( "No thumbnail regeneration needed for $att_desc." );
WP_CLI::log( "$progress No thumbnail regeneration needed for $att_desc." );
return true;
}
}
Expand Down