Commit 1535ad156d for wordpress.org
commit 1535ad156dc20084502fd4fdf87bfd2082787898
Author: John Blackbourn <johnbillion@git.wordpress.org>
Date: Sun Jun 29 22:27:28 2025 +0000
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
Built from https://develop.svn.wordpress.org/trunk@60365
git-svn-id: http://core.svn.wordpress.org/trunk@59701 1a063a9b-81f0-0310-95a4-ce76da25c4cd
diff --git a/wp-includes/post.php b/wp-includes/post.php
index 0006ae6454..d9efb1e06a 100644
--- a/wp-includes/post.php
+++ b/wp-includes/post.php
@@ -8170,6 +8170,10 @@ function wp_queue_posts_for_term_meta_lazyload( $posts ) {
* @param WP_Post $post Post object.
*/
function _update_term_count_on_transition_post_status( $new_status, $old_status, $post ) {
+ if ( $new_status === $old_status ) {
+ return;
+ }
+
// Update counts for the post's terms.
foreach ( (array) get_object_taxonomies( $post->post_type ) as $taxonomy ) {
$tt_ids = wp_get_object_terms( $post->ID, $taxonomy, array( 'fields' => 'tt_ids' ) );
diff --git a/wp-includes/version.php b/wp-includes/version.php
index 673714ba1e..10e6a2692c 100644
--- a/wp-includes/version.php
+++ b/wp-includes/version.php
@@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
-$wp_version = '6.9-alpha-60364';
+$wp_version = '6.9-alpha-60365';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.