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. Built from https://develop.svn.wordpress.org/trunk@41323 git-svn-id: http://core.svn.wordpress.org/trunk@41154 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
d611184f4f
commit
682ec35fbc
|
@ -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 ) );
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '4.9-alpha-41322';
|
||||
$wp_version = '4.9-alpha-41323';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue