[wp-trac] [WordPress Trac] #30009: _wp_put_post_revision checks for errors incorrectly

WordPress Trac noreply at wordpress.org
Fri Dec 26 16:36:52 UTC 2014


#30009: _wp_put_post_revision checks for errors incorrectly
--------------------------+------------------------------
 Reporter:  rmccue        |       Owner:  rmccue
     Type:  defect (bug)  |      Status:  assigned
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  Revisions     |     Version:  2.6
 Severity:  minor         |  Resolution:
 Keywords:  has-patch     |     Focuses:
--------------------------+------------------------------

Comment (by adamsilverstein):

 looks good. I updated the doc block slightly in  [attachment:30009.3.diff]
 to reflect the return value.

 I tried to write a unit test for this and couldn't actually get
 `wp_insert_post` to return an error - it only does so when get_post(
 post_id ) fails (returns null) and that check already happens earlier in
 `_wp_put_post_revision`.  For this reason, I believe we could remove the
 entire error check conditional, we are returning $revision_id in any
 case...

 Good catch in any case, the check as is will never work!

 Replying to [comment:1 rmccue]:
 > Attached patches specify that we want a `WP_Error` back from
 `wp_insert_post`, pretty straight forward patch.
 >
 > [attachment:30009.diff] fixes the problem, [attachment:30009.2.diff]
 goes a bit further and corrects coding standards in the function while
 we're in there.

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


More information about the wp-trac mailing list