[wp-trac] [WordPress Trac] #21963: Consolidate post insertion APIs

WordPress Trac noreply at wordpress.org
Wed May 28 19:53:49 UTC 2014


#21963: Consolidate post insertion APIs
--------------------------------------------------+------------------
 Reporter:  nacin                                 |       Owner:
     Type:  defect (bug)                          |      Status:  new
 Priority:  normal                                |   Milestone:  4.0
Component:  Posts, Post Types                     |     Version:
 Severity:  normal                                |  Resolution:
 Keywords:  has-patch needs-unit-tests 3.6-early  |     Focuses:
--------------------------------------------------+------------------

Comment (by kovshenin):

 It looks like update_attached_file() runs when updating the attachment,
 like adding a caption from the media modal, hence the _wp_attached_file
 meta value is gone. In wp_insert_attachment() we checked file with `if (
 $file )` before calling update_attached_file() which was false for
 updates, but in wp_insert_post() that became `isset()` which is always
 true because wp_insert_attachment() always sets the file argument.

 I attached two patches. [attachment:21963.6.diff] is against r28600
 (before the revert) which shows what went wrong + a unit test. And
 [attachment:21963.7.diff] which reverse-merges r28601 and applies .7.diff.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/21963#comment:28>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list