Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

When inserting orphaned attachment in a post, set post_parent only fo…

…r this attachment, fixes #8721

git-svn-id: http://svn.automattic.com/wordpress/branches/2.7@10435 1a063a9b-81f0-0310-95a4-ce76da25c4cd
  • Loading branch information...
commit d34a34af3e4dfaa87a07c3928e5e69bd3fd1fefc 1 parent 931052a
azaozz authored

Showing 1 changed file with 10 additions and 5 deletions. Show diff stats Hide diff stats

  1. +10 5 wp-admin/includes/media.php
15 wp-admin/includes/media.php
@@ -369,6 +369,11 @@ function media_buttons() {
369 369 function media_upload_form_handler() {
370 370 check_admin_referer('media-form');
371 371
  372 + if ( isset($_POST['send']) ) {
  373 + $keys = array_keys($_POST['send']);
  374 + $send_id = (int) array_shift($keys);
  375 + }
  376 +
372 377 if ( !empty($_POST['attachments']) ) foreach ( $_POST['attachments'] as $attachment_id => $attachment ) {
373 378 $post = $_post = get_post($attachment_id, ARRAY_A);
374 379 if ( isset($attachment['post_content']) )
@@ -379,8 +384,10 @@ function media_upload_form_handler() {
379 384 $post['post_excerpt'] = $attachment['post_excerpt'];
380 385 if ( isset($attachment['menu_order']) )
381 386 $post['menu_order'] = $attachment['menu_order'];
382   - if ( isset($attachment['post_parent']) )
383   - $post['post_parent'] = $attachment['post_parent'];
  387 + if ( isset($send_id) && $attachment_id == $send_id ) {
  388 + if ( isset($attachment['post_parent']) )
  389 + $post['post_parent'] = $attachment['post_parent'];
  390 + }
384 391
385 392 $post = apply_filters('attachment_fields_to_save', $post, $attachment);
386 393
@@ -408,9 +415,7 @@ function media_upload_form_handler() {
408 415 exit;
409 416 }
410 417
411   - if ( isset($_POST['send']) ) {
412   - $keys = array_keys($_POST['send']);
413   - $send_id = (int) array_shift($keys);
  418 + if ( isset($send_id) ) {
414 419 $attachment = stripslashes_deep( $_POST['attachments'][$send_id] );
415 420 $html = $attachment['post_title'];
416 421 if ( !empty($attachment['url']) ) {

0 comments on commit d34a34a

Please sign in to comment.
Something went wrong with that request. Please try again.