Ticket #3203: speed-up-topic-trashing.diff
File speed-up-topic-trashing.diff, 2.7 KB (added by , 6 years ago) |
---|
-
includes/forums/functions.php
1523 1523 'numberposts' => 1 1524 1524 ); 1525 1525 1526 // Get the most recent topic in this forum_id 1527 $recent_topic = get_posts( $post_vars ); 1526 // Get the most recent topic in this forum_id 1527 $recent_topic = wp_cache_get( 'bbp_recent_topic_forum_' . $forum_id ); 1528 if ( false === $recent_topic ) { 1529 $recent_topic = get_posts( $post_vars ); 1530 wp_cache_set( 'bbp_recent_topic_forum_' . $forum_id, $recent_topic ); 1531 } 1532 1528 1533 if ( ! empty( $recent_topic ) ) { 1529 1534 $topic_id = $recent_topic[0]->ID; 1530 1535 } … … 1588 1593 if ( ! empty( $topic_ids ) ) { 1589 1594 1590 1595 // ...get the most recent reply from those topics... 1591 $reply_id = bbp_forum_query_last_reply_id( $forum_id, $topic_ids ); 1592 1596 $topic_id_hash = md5( json_encode( $topic_ids ) ); 1597 $reply_id = wp_cache_get( 'bbp_forum_query_last_reply_id_' . $forum_id . $topic_id_hash ); 1598 if ( false === $reply_id ) { 1599 $reply_id = bbp_forum_query_last_reply_id( $forum_id, $topic_ids ); 1600 wp_cache_set( 'bbp_forum_query_last_reply_id_' . $forum_id . $topic_id_hash, $reply_id ); 1601 } 1602 1593 1603 // ...and compare it to the most recent topic id... 1594 1604 $reply_id = ( $reply_id > max( $topic_ids ) ) ? $reply_id : max( $topic_ids ); 1595 1605 } … … 1653 1663 // Don't count replies if the forum is a category 1654 1664 $topic_ids = bbp_forum_query_topic_ids( $forum_id ); 1655 1665 if ( ! empty( $topic_ids ) ) { 1656 $active_id = bbp_forum_query_last_reply_id( $forum_id, $topic_ids ); 1666 $topic_id_hash = md5( json_encode( $topic_ids ) ); 1667 $active_id = wp_cache_get( 'bbp_forum_query_last_reply_id_' . $forum_id . $topic_id_hash ); 1668 if ( false === $active_id ) { 1669 $active_id = bbp_forum_query_last_reply_id( $forum_id, $topic_ids ); 1670 wp_cache_set( 'bbp_forum_query_last_reply_id_' . $forum_id . $topic_id_hash, $active_id ); 1671 } 1657 1672 $active_id = $active_id > max( $topic_ids ) ? $active_id : max( $topic_ids ); 1658 1673 1659 1674 // Forum has no topics … … 2268 2283 * and forum id 2269 2284 */ 2270 2285 function bbp_forum_query_topic_ids( $forum_id ) { 2271 $topic_ids = bbp_get_public_child_ids( $forum_id, bbp_get_topic_post_type() ); 2272 2286 $topic_ids = wp_cache_get( 'bbp_get_public_child_ids_forum_' . $forum_id ); 2287 if ( false === $topic_ids ) { 2288 $topic_ids = bbp_get_public_child_ids( $forum_id, bbp_get_topic_post_type() ); 2289 wp_cache_set( 'bbp_get_public_child_ids_forum_' . $forum_id, $topic_ids ); 2290 } 2273 2291 return (array) apply_filters( 'bbp_forum_query_topic_ids', $topic_ids, $forum_id ); 2274 2292 } 2275 2293