wp-cli / media-command

Imports files as attachments, regenerates thumbnails, or lists registered image sizes.
MIT License
44 stars 41 forks source link

Dead code in media command class #190

Closed ernilambar closed 6 months ago

ernilambar commented 6 months ago

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/

danielbachhuber commented 6 months ago

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

https://github.com/wp-cli/media-command/blob/8717808232e4137b291496aecdadacc8b4d6c95b/php/commands/media.php#L70-L75

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).