WordPress.org

Make WordPress Core

Opened 7 years ago

Closed 7 years ago

Last modified 6 years ago

#8721 closed defect (bug) (fixed)

attach logic is overenthusiastic: inserting a single item from Media Library sets post_parent of every item listed in Add Media overlay

Reported by: dhalbert Owned by:
Milestone: 2.7.1 Priority: normal
Severity: normal Version: 2.7
Component: Media Keywords:
Focuses: Cc:

Description

I am getting spurious Attached to settings when inserting Media Library items into a post.

How to reproduce:

Add a bunch of files to the Media Library . (I added a bunch of existing pdf files using the Add From Server plugin.) All are inserted into table wp_posts with post_parent=0, so they are unattached.

Create a new post, and click on the Add Media icon, which brings up the Add Media overlay.

Choose the Media Library tab, which shows the first 10 items in the Media Library. Click on Show for one of these: the entry expands. Edit the Title slightly (may not be necessary), and then click on Insert into Post.

The Add Media overlay goes away. Finish editing the post and publish it.

Now browse the Media Library. You will discover that the Attach To column shows that all ten of the items mentioned above are listed as attachments of the post you just created. The post_parent for all ten items shown in the Media Library list has been set to the id of that post, even though you only inserted one item from the list of ten.

So the attach logic mistakenly thinks everything in that Media Library list should be attached, instead of just the inserted item.

Change History (9)

comment:1 @dhalbert7 years ago

  • Milestone changed from 2.8 to 2.7.1

comment:2 follow-up: @Denis-de-Bernardy7 years ago

are you sure you don't have a plugin active or something? It seems to be working fine on my end in the latest 2.7 branch

comment:3 @DD327 years ago

I've seen this too.

  • upload a tonne of files which are not attached to a post
  • Open a post, Insert one of the images
  • Close insert image dialogue
  • open image dialogue again, notice a heap of images in the gallery

comment:4 in reply to: ↑ 2 @dhalbert7 years ago

Replying to Denis-de-Bernardy:

are you sure you don't have a plugin active or something? It seems to be working fine on my end in the latest 2.7 branch

The only plugin installed was "Add From Server".

When you say "latest 2.7 branch" , do you mean the publicly available 2.7 download (what I am using), or the latest 2.7 from SVN (which I thought would be no different from the former)?

comment:5 @azaozz7 years ago

(In [10390]) When inserting orphaned attachment in a post, set post_parent only for this attachment, see #8721

comment:6 @azaozz7 years ago

The patch may need some testing before adding it in 2.7.x

comment:7 @Denis-de-Bernardy7 years ago

dhalbert -- the 2.7 svn branch

comment:8 @ryan7 years ago

  • Component changed from General to Media
  • Owner anonymous deleted

comment:9 @azaozz7 years ago

  • Resolution set to fixed
  • Status changed from new to closed

(In [10435]) When inserting orphaned attachment in a post, set post_parent only for this attachment, fixes #8721

Note: See TracTickets for help on using tickets.