Ticket #8721 (closed defect (bug): fixed)

Opened 3 years ago

Last modified 2 years ago

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:
Priority: normal Milestone: 2.7.1
Component: Media Version: 2.7
Severity: normal Keywords:
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

  • Milestone changed from 2.8 to 2.7.1

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   DD323 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   dhalbert3 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)?

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

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

dhalbert -- the 2.7 svn branch

comment:8   ryan3 years ago

  • Owner anonymous deleted
  • Component changed from General to Media
  • Status changed from new to closed
  • Resolution set to fixed

(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.