Changeset 7905
- Timestamp:
- 02/17/2014 01:02:25 AM (11 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-activity/bp-activity-classes.php
r7901 r7905 249 249 * Default: false. 250 250 * @type string $spam Spam status. Default: 'ham_only'. 251 * @type bool $update_meta_cache Whether to pre-fetch metadata for 252 * queried activity items. Default: true. 251 253 * } 252 254 * @return array The array returned has two keys: … … 431 433 } 432 434 433 if ( ! empty( $activity_ids )) {435 if ( ! empty( $activity_ids ) && $update_meta_cache ) { 434 436 bp_activity_update_meta_cache( $activity_ids ); 435 437 } -
trunk/bp-activity/bp-activity-functions.php
r7885 r7905 911 911 'in' => false, // Comma-separated list or array of activity IDs to which you want to limit the query 912 912 'spam' => 'ham_only', // 'ham_only' (default), 'spam_only' or 'all'. 913 'update_meta_cache' => true, 913 914 914 915 /** … … 940 941 'display_comments' => $display_comments, 941 942 'show_hidden' => $show_hidden, 942 'spam' => $spam 943 'spam' => $spam, 944 'update_meta_cache' => $update_meta_cache, 943 945 ); 944 946 $activity = BP_Activity_Activity::get( $args ); … … 981 983 * except for the following: 982 984 * @type string|int|array Single activity ID, comma-separated list of IDs, 983 * 985 * or array of IDs. 984 986 * } 985 987 * @return array $activity See BP_Activity_Activity::get() for description. … … 995 997 'sort' => 'DESC', // sort ASC or DESC 996 998 'spam' => 'ham_only', // Retrieve items marked as spam 999 'update_meta_cache' => true, 997 1000 ); 998 1001 $r = wp_parse_args( $args, $defaults ); … … 1007 1010 'show_hidden' => $show_hidden, 1008 1011 'in' => $activity_ids, 1009 'spam' => $spam 1012 'spam' => $spam, 1013 'update_meta_cache' => $update_meta_cache, 1010 1014 ); 1011 1015 return apply_filters( 'bp_activity_get_specific', BP_Activity_Activity::get( $get_args ), $args, $get_args ); -
trunk/bp-activity/bp-activity-template.php
r7899 r7905 174 174 'show_hidden' => false, 175 175 'spam' => 'ham_only', 176 'update_meta_cache' => true, 176 177 ); 177 178 $r = wp_parse_args( $args, $defaults ); … … 189 190 // Fetch specific activity items based on ID's 190 191 if ( !empty( $include ) ) 191 $this->activities = bp_activity_get_specific( array( 'activity_ids' => explode( ',', $include ), 'max' => $max, 'page' => $this->pag_page, 'per_page' => $this->pag_num, 'sort' => $sort, 'display_comments' => $display_comments, 'show_hidden' => $show_hidden, 'spam' => $spam ) );192 $this->activities = bp_activity_get_specific( array( 'activity_ids' => explode( ',', $include ), 'max' => $max, 'page' => $this->pag_page, 'per_page' => $this->pag_num, 'sort' => $sort, 'display_comments' => $display_comments, 'show_hidden' => $show_hidden, 'spam' => $spam, 'update_meta_cache' => $update_meta_cache, ) ); 192 193 193 194 // Fetch all activity items 194 195 else 195 $this->activities = bp_activity_get( array( 'display_comments' => $display_comments, 'max' => $max, 'per_page' => $this->pag_num, 'page' => $this->pag_page, 'sort' => $sort, 'search_terms' => $search_terms, 'meta_query' => $meta_query, 'filter' => $filter, 'show_hidden' => $show_hidden, 'exclude' => $exclude, 'in' => $in, 'spam' => $spam ) );196 $this->activities = bp_activity_get( array( 'display_comments' => $display_comments, 'max' => $max, 'per_page' => $this->pag_num, 'page' => $this->pag_page, 'sort' => $sort, 'search_terms' => $search_terms, 'meta_query' => $meta_query, 'filter' => $filter, 'show_hidden' => $show_hidden, 'exclude' => $exclude, 'in' => $in, 'spam' => $spam, 'update_meta_cache' => $update_meta_cache, ) ); 196 197 197 198 if ( !$max || $max >= (int) $this->activities['total'] ) … … 449 450 * @type string|bool $spam Spam status. 'ham_only', 'spam_only', or false 450 451 * to show all activity regardless of spam status. Default: 'ham_only'. 452 * @type bool $populate_extras Whether to pre-fetch the activity metadata 453 * for the queried items. Default: true. 451 454 * } 452 455 * @return bool Returns true when activities are found, otherwise false. … … 520 523 521 524 // Searching 522 'search_terms' => false // specify terms to search on 525 'search_terms' => false, // specify terms to search on 526 'update_meta_cache' => true, 523 527 ); 524 528 … … 627 631 'display_comments' => $display_comments, 628 632 'show_hidden' => $show_hidden, 629 'spam' => $spam 633 'spam' => $spam, 634 'update_meta_cache' => $update_meta_cache, 630 635 ); 631 636 -
trunk/tests/testcases/activity/template.php
r7574 r7905 254 254 255 255 } 256 257 /** 258 * @group bp_has_activities 259 * @group cache 260 */ 261 public function test_bp_has_activities_with_update_meta_cache_false() { 262 $now = time(); 263 $a1 = $this->factory->activity->create( array( 264 'content' => 'Life Rules', 265 'recorded_time' => date( 'Y-m-d H:i:s', $now ), 266 ) ); 267 $a2 = $this->factory->activity->create( array( 268 'content' => 'Life Drools', 269 'recorded_time' => date( 'Y-m-d H:i:s', $now - 100 ), 270 ) ); 271 272 bp_activity_add_meta( $a1, 'foo', 'bar' ); 273 bp_activity_add_meta( $a2, 'foo1', 'bar2' ); 274 275 // prime 276 bp_has_activities( array( 277 'update_meta_cache' => false, 278 ) ); 279 280 $this->assertFalse( wp_cache_get( $a1, 'activity_meta' ) ); 281 $this->assertFalse( wp_cache_get( $a2, 'activity_meta' ) ); 282 } 283 284 /** 285 * @group bp_has_activities 286 * @group cache 287 */ 288 public function test_bp_has_activities_with_update_meta_cache_true() { 289 $now = time(); 290 $a1 = $this->factory->activity->create( array( 291 'content' => 'Life Rules', 292 'recorded_time' => date( 'Y-m-d H:i:s', $now ), 293 ) ); 294 $a2 = $this->factory->activity->create( array( 295 'content' => 'Life Drools', 296 'recorded_time' => date( 'Y-m-d H:i:s', $now - 100 ), 297 ) ); 298 299 bp_activity_add_meta( $a1, 'foo', 'bar' ); 300 bp_activity_add_meta( $a2, 'foo1', 'bar2' ); 301 302 // prime 303 bp_has_activities( array( 304 'update_meta_cache' => true, 305 ) ); 306 307 $this->assertNotEmpty( wp_cache_get( $a1, 'activity_meta' ) ); 308 $this->assertNotEmpty( wp_cache_get( $a2, 'activity_meta' ) ); 309 } 256 310 }
Note: See TracChangeset
for help on using the changeset viewer.