WordPress.org

Make WordPress Core

Opened 14 months ago

Last modified 8 months ago

#27736 new enhancement

Save one query when inserting a new post

Reported by: ozh Owned by:
Milestone: Awaiting Review Priority: normal
Severity: minor Version: 3.0
Component: Posts, Post Types Keywords: has-patch needs-refresh
Focuses: administration, performance Cc:

Description

The workflow when inserting a new post is the following :

1) wp_insert_post() sets a few vars (post type, post status, ...), updates $wpdb->posts, then calls wp_set_post_categories()

2) first thing wp_set_post_categories() wants to know is $post_type and $post_status, for which it performs an SQL query, instead of getting this info from caller function

Same things goes for wp_insert_attachment()

Patch passes extra optional parameters $post_type and $post_status to wp_set_post_categories(), to save one query when adding a post, or a whole bunch when importing a batch.

Attachments (4)

27736.post.php.patch (1.5 KB) - added by ozh 14 months ago.
27736.post.php.2.patch (1.8 KB) - added by ozh 14 months ago.
fix wp_insert_attachment() as well
27736.post.php.3.patch (1.8 KB) - added by ozh 14 months ago.
sorry, coding standards... tabs, not spaces
27736.post.php.4.patch (2.1 KB) - added by ozh 14 months ago.
More coding standards: braces on all if

Download all attachments as: .zip

Change History (10)

@ozh14 months ago

@ozh14 months ago

fix wp_insert_attachment() as well

comment:1 @ozh14 months ago

  • Focuses administration performance added
  • Keywords has-patch added

@ozh14 months ago

sorry, coding standards... tabs, not spaces

comment:2 @DrewAPicture14 months ago

This seems pretty straightforward. We're also now always using braces on all if statements.

@ozh14 months ago

More coding standards: braces on all if

comment:3 @johnbillion14 months ago

  • Severity changed from normal to minor
  • Version changed from trunk to 3.0

comment:4 @ozh12 months ago

(why 3.0 ?)

comment:5 @johnbillion12 months ago

The issue was introduced in version 3.0 ([13184] and [14883]).

comment:6 @wonderboymusic8 months ago

  • Keywords needs-refresh added

The patch does not apply and seems to ignore all of the changes made in 4.0 (extract() removal, et al)

Note: See TracTickets for help on using tickets.