Media: media_handle_sideload() expectes wp_insert_attachment() to return a WP_Error.

For `wp_insert_attachment()` to do that, we need to be setting the `$wp_error` parameter to true.

Props subrataemfluence, jirihon.
Fixes #44303.



git-svn-id: https://develop.svn.wordpress.org/trunk@44634 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Gary Pendergast 2019-01-17 06:26:05 +00:00
parent 2e63f69564
commit 7303470ecd

View File

@ -467,7 +467,7 @@ function media_handle_sideload( $file_array, $post_id, $desc = null, $post_data
unset( $attachment['ID'] );
// Save the attachment metadata
$id = wp_insert_attachment( $attachment, $file, $post_id );
$id = wp_insert_attachment( $attachment, $file, $post_id, true );
if ( ! is_wp_error( $id ) ) {
wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $file ) );
}