PluginProbe
bbPress / 2.6.17
bbPress v2.6.17
2.6.17 trunk 2.0 2.0-beta-1 2.0-beta-2b 2.0-beta-3 2.0-beta-3b 2.0-rc-2 2.0-rc-3 2.0-rc-4 2.0-rc-5 2.0.1 2.0.2 2.0.3 2.1 2.1-beta-1 2.1-rc1 2.1-rc2 2.1-rc3 2.1-rc4 2.1.1 2.1.2 2.1.3 2.2 2.2.1 All 72 releases
← All changes | includes/core/cache.php +13 -40 trunk2.6.17 View file →
@@ -1,8 +1,8 @@
1 1 <?php
2 2
3 3 /**
4 - * bbPress Cache Helpers.
4 + * bbPress Cache Helpers
5 5 *
6 6 * Helper functions used to communicate with WordPress's various caches. Many
7 7 * of these functions are used to work around specific WordPress nuances. They
8 8 * are subject to changes, tweaking, and will need iteration as performance
@@ -33,14 +33,14 @@
33 33 */
34 34 class BBP_Skip_Children {
35 35
36 36 /**
37 - * @var int Post ID being updated.
37 + * @var int Post ID being updated
38 38 */
39 39 private $updating_post = 0;
40 40
41 41 /**
42 - * @var bool The original value of $_wp_suspend_cache_invalidation global.
42 + * @var bool The original value of $_wp_suspend_cache_invalidation global
43 43 */
44 44 private $original_cache_invalidation = false;
45 45
46 46 /** Methods ***************************************************************/
@@ -62,9 +62,10 @@
62 62 * prevents child post caches from being cleared.
63 63 *
64 64 * @since 2.1.0 bbPress (r4011)
65 65 *
66 - * @param int $post_id The post ID being updated.
66 + * @param int $post_id The post ID being updated
67 + * @return If invalid post data
67 68 */
68 69 public function pre_post_update( $post_id = 0 ) {
69 70
70 71 // Bail if post ID is not a bbPress post type
@@ -80,18 +81,15 @@
80 81 add_action( 'clean_post_cache', array( $this, 'skip_related_posts' ) );
81 82 }
82 83
83 84 /**
84 - * Suspend child post cache invalidation after the updated post is cleaned.
85 + * Skip cache invalidation of related posts if the post ID being invalidated
86 + * is not the one that was just updated.
85 87 *
86 - * The updated post triggers this callback first. Suspending invalidation here
87 - * prevents WordPress from clearing its children during the same update.
88 - *
89 88 * @since 2.1.0 bbPress (r4011)
90 89 *
91 - * @global bool $_wp_suspend_cache_invalidation Whether cache invalidation is suspended.
92 - *
93 - * @param int $post_id The post ID of the cache being invalidated.
90 + * @param int $post_id The post ID of the cache being invalidated
91 + * @return If invalid post data
94 92 */
95 93 public function skip_related_posts( $post_id = 0 ) {
96 94
97 95 // Bail if this post is not the current bbPress post
@@ -124,18 +122,17 @@
124 122
125 123 /** General *******************************************************************/
126 124
127 125 /**
128 - * Invalidate parent post caches after a bbPress post cache is cleaned.
126 + * Will clean a post in the cache.
129 127 *
130 - * Recurses through parent posts and updates the bbpress_posts last_changed
131 - * cache value when the forum root is reached. Runs on clean_post_cache.
128 + * Will call to clean the term object cache associated with the post ID.
132 129 *
133 130 * @since 2.1.0 bbPress (r4040)
134 131 * @since 2.6.0 bbPress (r6053) Introduced the `$post_id` parameter.
135 132 *
136 - * @param int $post_id ID supplied by clean_post_cache. The post object supplies the ID used here.
137 - * @param WP_Post $post Required post object supplied by clean_post_cache.
133 + * @param int $post_id The post id.
134 + * @param WP_Post $post The WP_Post object.
138 135 */
139 136 function bbp_clean_post_cache( $post_id = null, $post = null ) {
140 137
141 138 // Child query types to clean
@@ -166,30 +163,6 @@
166 163
167 164 // Only bump `last_changed` when forum-root is reached
168 165 } else {
169 166 wp_cache_set( 'last_changed', microtime(), 'bbpress_posts' );
170 - }
171 -}
172 -
173 -/**
174 - * Invalidate cached forum-user counts across sites sharing the users table.
175 - *
176 - * @since 2.7.0
177 - */
178 -function bbp_clean_user_count_cache() {
179 - wp_cache_set( 'bbp_forum_users_last_changed', microtime(), 'users' );
180 -}
181 -
182 -/**
183 - * Invalidate forum-user counts after capabilities metadata changes.
184 - *
185 - * @since 2.7.0
186 - *
187 - * @param int|array $meta_id Metadata ID or IDs.
188 - * @param int $user_id User ID.
189 - * @param string $key Metadata key.
190 - */
191 -function bbp_clean_user_count_cache_on_meta_change( $meta_id, $user_id, $key ) {
192 - if ( preg_match( '/(^|_)capabilities$/', $key ) ) {
193 - bbp_clean_user_count_cache();
194 167 }
195 168 }