Skip to content

Dead code in media command class #190

Closed

Description

@ernilambar

Bug Report

Describe the current, buggy behavior

Line 627 : https://github.com/wp-cli/media-command/blob/main/src/Media_Command.php#L627

There is conditional of is_wp_error() for $metadata which is output of wp_generate_attachment_metadata(). Since this function always return an array, my VSCode is flagging as error. Not sure about the background of the code. So mentioning here as an issue.

Ref: https://developer.wordpress.org/reference/functions/wp_generate_attachment_metadata/

Activity

  1. danielbachhuber commented on Feb 20, 2024

    @danielbachhuber
    Member

    It looks like this code has been in here for quite a while:

    $metadata = wp_generate_attachment_metadata( $image->ID, $fullsizepath );
    if ( is_wp_error( $metadata ) ) {
    WP_CLI::warning( $metadata->get_error_message() );
    return;
    }

    I'd be open to removing it if we have sufficient test coverage around it (e.g. a test case for the empty attachment data scenario).

  2. added
    command:media-regenerate
    command:media
    on Feb 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    command:mediacommand:media-regeneratecontributor-day

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions