Media: Ensure 'media_handle_upload()' returns 'WP_Error' on failure.
This fixes an issue where failures when inserting the attachment post via `wp_insert_attachment()` would result in a return value of `0` instead of a `WP_Error` object, as documented. This is addressed by passing `true` as the fourth param (added in WP 4.7.0) when calling `wp_insert_attachment()`. Props mrasharirfan, flixos90. Fixes #41726. git-svn-id: https://develop.svn.wordpress.org/trunk@41323 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
2873bcd69c
commit
06329dc35e
@ -378,7 +378,7 @@ function media_handle_upload($file_id, $post_id, $post_data = array(), $override
|
||||
unset( $attachment['ID'] );
|
||||
|
||||
// Save the data
|
||||
$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 ) );
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user