Make WordPress Core

Opened 8 years ago

Closed 7 months ago

Last modified 3 months ago

#42522 closed defect (bug) (fixed)

Terms are uselessly counted when saving a post

Reported by: chouby's profile Chouby Owned by: johnbillion's profile johnbillion
Milestone: 6.9 Priority: normal
Severity: normal Version: 3.3
Component: Taxonomy Keywords: has-patch has-unit-tests
Focuses: performance Cc:

Description

This occurs even when terms have not been modified and when the post status has not changed. This is due to _update_term_count_on_transition_post_status not checking if the post status has been modified.

Attachments (1)

42522.diff (950 bytes) - added by Chouby 8 years ago.

Download all attachments as: .zip

Change History (11)

@Chouby
8 years ago

#1 @Chouby
8 years ago

  • Keywords has-patch added

#2 @johnbillion
8 years ago

  • Keywords reporter-feedback added

What about the situation where a published post gets its terms changed but the status doesn't change? It looks like this change would cause the term count for newly added terms to get out of sync.

#3 @Chouby
8 years ago

  • Keywords reporter-feedback removed

In that case, wp_set_object_terms calls wp_update_term_count, so the term count should be correctly udpated.

This ticket was mentioned in PR #6793 on WordPress/wordpress-develop by @pbearne.


19 months ago
#4

The modification ensures that term counts are only updated when the post's status has truly changed. This reduces unnecessary operations, improving performance when there is no status change on a post.

#5 @pbearne
19 months ago

  • Owner set to pbearne
  • Status changed from new to assigned

refreshed patch

#6 @pbearne
19 months ago

  • Keywords has-unit-tests added

#7 @johnbillion
7 months ago

  • Milestone changed from Awaiting Review to 6.9
  • Owner changed from pbearne to johnbillion
  • Status changed from assigned to reviewing

#8 @johnbillion
7 months ago

  • Resolution set to fixed
  • Status changed from reviewing to closed

In 60365:

Taxonomy: Avoid unnecessarily recalculating term counts when a post is updated and its status is unchanged.

If the terms of the post are changed then the term recounting is still handled by wp_update_term_count() inside wp_set_object_terms().

Props pbearne, johnbillion, peterwilsoncc, Chouby

Fixes #42522

This ticket was mentioned in Slack in #core-performance by johnbillion. View the logs.


4 months ago

This ticket was mentioned in Slack in #core by westonruter. View the logs.


3 months ago

Note: See TracTickets for help on using tickets.