Make WordPress Core

Opened 4 years ago

Closed 4 years ago

#56279 closed enhancement (fixed)

Use wp_get_latest_revision_id_and_total_count() where appropriate

Reported by: SergeyBiryukov Owned by: SergeyBiryukov
Priority: normal Milestone: 6.1
Component: Revisions Version: 6.1
Severity: normal Keywords: has-patch
Cc: Focuses:

Description (last modified by SergeyBiryukov)

Background: #55857

A new function wp_get_latest_revision_id_and_total_count(), with an optimized query to get the last revision ID and total count, was introduced in [53759], [53769], and [53778].

As noted in comment:4:ticket:55857, there are a few other places in core that could use it.

Attachments (3)

56279.diff​ (2.1 KB ) - added by SergeyBiryukov 4 years ago.
56279.2.diff​ (1.7 KB ) - added by SergeyBiryukov 4 years ago.
56279.3.diff​ (2.2 KB ) - added by SergeyBiryukov 4 years ago.

Download all attachments as: .zip

Change History (9)

#1 @mukesh27
4 years ago

  • Keywords needs-refresh added

One extra semicolon is added in the patch, file wp-includes\revision.php. Can you please remove it?

#2 follow-up: @peterwilsoncc
4 years ago

I've reopened #55857 to rename the function to wp_get_latest_revision_id_and_total_count() so the function follows the conventional term used for getting latest posts, comments, etc.

Please hold of committing this change until the rename is complete.

#3 in reply to: ↑ 2 @SergeyBiryukov
4 years ago

  • Keywords needs-refresh removed

Replying to peterwilsoncc:

I've reopened #55857 to rename the function to wp_get_latest_revision_id_and_total_count() so the function follows the conventional term used for getting latest posts, comments, etc.

Thanks! 56279.2.diff​ switches to "latest" and removes the extra semicolon from the previous patch.

There may be more instances where the function can be used, these are just the ones I found at a glance.

#4 @SergeyBiryukov
4 years ago

  • Description modified (diff)
  • Summary Use wp_get_last_revision_id_and_total_count() where appropriate → Use wp_get_latest_revision_id_and_total_count() where appropriate

#5 @SergeyBiryukov
4 years ago

Refreshed after [53841]. Found one more place to use this in wp_update_custom_css_post().

#6 @SergeyBiryukov
4 years ago

  • Owner set to SergeyBiryukov
  • Resolution → fixed
  • Status new → closed

In 53842:

Revisions: Use wp_get_latest_revision_id_and_total_count() where appropriate.

The function executes an optimized query to get the last revision ID and total count. It was originally introduced for WP_REST_Posts_Controller::prepare_links(), and is now used in a few more places in core:

  • register_and_do_post_meta_boxes()
  • wp_get_post_revisions_url()
  • wp_update_custom_css_post()

Follow-up to [53759], [53769], [53778], [53779], [53841].

Props peterwilsoncc, mukesh27, SergeyBiryukov.
Fixes #56279.

Note: See TracTickets for help on using tickets.