From 682ec35fbc8f73a59cbbd8dbb5ee11fee720bbb8 Mon Sep 17 00:00:00 2001 From: Joe McGill Date: Wed, 30 Aug 2017 15:04:48 +0000 Subject: [PATCH] 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 --- wp-admin/includes/media.php | 2 +- wp-includes/version.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/wp-admin/includes/media.php b/wp-admin/includes/media.php index 4a2e7c2e72..702a727ef4 100644 --- a/wp-admin/includes/media.php +++ b/wp-admin/includes/media.php @@ -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 ) ); } diff --git a/wp-includes/version.php b/wp-includes/version.php index 10f09c524d..5c6f72a14e 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -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.