WordPress.org

Make WordPress Core

Opened 8 years ago

Closed 8 years ago

#22167 closed defect (bug) (fixed)

Categories revert to default when scheduled posts are published

Reported by: danielbachhuber Owned by: nacin
Milestone: 3.5 Priority: normal
Severity: major Version: 3.5
Component: General Keywords:
Focuses: Cc:

Description

The issue is that a scheduled post's categories are dropped when it's published. check_and_publish_future_post() calls wp_publish_post():

http://core.trac.wordpress.org/browser/trunk/wp-includes/post.php#L2882

which, in turn, gets a WP_Post object, changes the status, can calls wp_insert_post():

http://core.trac.wordpress.org/browser/trunk/wp-includes/post.php#L2863

but, because post_category isn't a part of the WP_Post object, the categories default to default

r21942 seems to be the culprit. This is reproducible on wpcom and in trunk.

Attachments (1)

22167.patch (518 bytes) - added by ericmann 8 years ago.
Replaces wp_insert_post() with wp_update_post() and fixes the issue

Download all attachments as: .zip

Change History (3)

#1 @SergeyBiryukov
8 years ago

  • Milestone changed from Awaiting Review to 3.5
  • Version set to trunk

@ericmann
8 years ago

Replaces wp_insert_post() with wp_update_post() and fixes the issue

#2 @nacin
8 years ago

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

In [22189]:

Use wp_update_post() rather than wp_insert_post() in wp_publish_post() to avoid stomping of values like categories. props ericmann, fixes #22167. see #21963.

Note: See TracTickets for help on using tickets.