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