X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/e9d988989fe37ab8c5f903e47fbe36e6e00dc51f..refs/tags/wordpress-3.1.4:/wp-admin/includes/media.php diff --git a/wp-admin/includes/media.php b/wp-admin/includes/media.php index 7e27ded1..99deac5a 100644 --- a/wp-admin/includes/media.php +++ b/wp-admin/includes/media.php @@ -228,6 +228,10 @@ function media_handle_upload($file_id, $post_id, $post_data = array(), $override 'post_content' => $content, ), $post_data ); + // This should never be set as it would then overwrite an existing attachment. + if ( isset( $attachment['ID'] ) ) + unset( $attachment['ID'] ); + // Save the data $id = wp_insert_attachment($attachment, $file, $post_id); if ( !is_wp_error($id) ) { @@ -281,6 +285,10 @@ function media_handle_sideload($file_array, $post_id, $desc = null, $post_data = 'post_content' => $content, ), $post_data ); + // This should never be set as it would then overwrite an existing attachment. + if ( isset( $attachment['ID'] ) ) + unset( $attachment['ID'] ); + // Save the attachment metadata $id = wp_insert_attachment($attachment, $file, $post_id); if ( !is_wp_error($id) ) @@ -419,6 +427,11 @@ function media_upload_form_handler() { if ( !empty($_POST['attachments']) ) foreach ( $_POST['attachments'] as $attachment_id => $attachment ) { $post = $_post = get_post($attachment_id, ARRAY_A); + $post_type_object = get_post_type_object( $post[ 'post_type' ] ); + + if ( !current_user_can( $post_type_object->cap->edit_post, $attachment_id ) ) + continue; + if ( isset($attachment['post_content']) ) $post['post_content'] = $attachment['post_content']; if ( isset($attachment['post_title']) )