Changeset 10217
- Timestamp:
- 10/08/2015 04:59:40 PM (9 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-activity/bp-activity-functions.php
r10184 r10217 1435 1435 * 1436 1436 * @since 1.2.0 1437 * @since 2.4.0 Introduced the `$fields` parameter. 1437 1438 * 1438 1439 * @see BP_Activity_Activity::get() For more information on accepted arguments … … 1452 1453 $r = bp_parse_args( $args, array( 1453 1454 'max' => false, // Maximum number of results to return 1455 'fields' => 'all', 1454 1456 'page' => 1, // page 1 without a per_page will result in no pagination. 1455 1457 'per_page' => false, // results per page … … 1483 1485 1484 1486 // Attempt to return a cached copy of the first page of sitewide activity. 1485 if ( ( 1 === (int) $r['page'] ) && empty( $r['max'] ) && empty( $r['search_terms'] ) && empty( $r['meta_query'] ) && empty( $r['date_query'] ) && empty( $r['filter_query'] ) && empty( $r['filter'] ) && empty( $r['scope'] )&& empty( $r['exclude'] ) && empty( $r['in'] ) && ( 'DESC' === $r['sort'] ) && empty( $r['exclude'] ) && ( 'ham_only' === $r['spam'] ) ) {1487 if ( ( 1 === (int) $r['page'] ) && empty( $r['max'] ) && ( 'all' === $r['fields'] ) && empty( $r['search_terms'] ) && empty( $r['meta_query'] ) && empty( $r['date_query'] ) && empty( $r['filter_query'] ) && empty( $r['filter'] ) && empty( $r['scope'] )&& empty( $r['exclude'] ) && empty( $r['in'] ) && ( 'DESC' === $r['sort'] ) && empty( $r['exclude'] ) && ( 'ham_only' === $r['spam'] ) ) { 1486 1488 1487 1489 $activity = wp_cache_get( 'bp_activity_sitewide_front', 'bp' ); … … 1492 1494 'per_page' => $r['per_page'], 1493 1495 'max' => $r['max'], 1496 'fields' => $r['fields'], 1494 1497 'sort' => $r['sort'], 1495 1498 'search_terms' => $r['search_terms'], -
trunk/src/bp-activity/bp-activity-template.php
r10160 r10217 271 271 'page_arg' => 'acpage', 272 272 'max' => false, 273 'fields' => 'all', 273 274 'count_total' => false, 274 275 'sort' => false, … … 508 509 * 509 510 * @since 1.0.0 511 * @since 2.4.0 Introduced the `$fields` parameter. 510 512 * 511 513 * @global object $activities_template {@link BP_Activity_Template} … … 537 539 * @type string $page_arg String used as a query parameter in pagination links. Default: 'acpage'. 538 540 * @type int|bool $max Maximum number of results to return. Default: false (unlimited). 541 * @type string $fields Activity fields to retrieve. 'all' to fetch entire activity objects, 542 * 'ids' to get only the activity IDs. Default 'all'. 539 543 * @type string|bool $count_total If true, an additional DB query is run to count the total activity items 540 544 * for the query. Default: false. … … 662 666 'page_arg' => 'acpage', // See https://buddypress.trac.wordpress.org/ticket/3679 663 667 'max' => false, // max number to return 668 'fields' => 'all', 664 669 'count_total' => false, 665 670 'show_hidden' => $show_hidden, // Show activity items that are hidden site-wide? -
trunk/src/bp-activity/classes/class-bp-activity-activity.php
r10210 r10217 261 261 * Get activity items, as specified by parameters. 262 262 * 263 * @since 1.0.0 264 * @since 2.4.0 Introduced the `$fields` parameter. 265 * 263 266 * @see BP_Activity_Activity::get_filter_sql() for a description of the 264 267 * 'filter' parameter. … … 273 276 * @type int|bool $per_page Number of results per page. Default: 25. 274 277 * @type int|bool $max Maximum number of results to return. Default: false (unlimited). 278 * @type string $fields Activity fields to return. Pass 'ids' to get only the activity IDs. 279 * 'all' returns full activity objects. 275 280 * @type string $sort ASC or DESC. Default: 'DESC'. 276 281 * @type array $exclude Array of activity IDs to exclude. Default: false. … … 324 329 'per_page' => 25, // Activity items per page 325 330 'max' => false, // Max number of items to return 331 'fields' => 'all', 326 332 'sort' => 'DESC', // ASC or DESC 327 333 'exclude' => false, // Array of ids to exclude … … 571 577 } 572 578 573 $activities = self::get_activity_data( $activity_ids ); 574 } 575 576 // Get the fullnames of users so we don't have to query in the loop 577 $activities = self::append_user_fullnames( $activities ); 578 579 // Get activity meta 580 $activity_ids = array(); 581 foreach ( (array) $activities as $activity ) { 582 $activity_ids[] = $activity->id; 583 } 584 585 if ( ! empty( $activity_ids ) && $r['update_meta_cache'] ) { 586 bp_activity_update_meta_cache( $activity_ids ); 587 } 588 589 if ( $activities && $r['display_comments'] ) { 590 $activities = BP_Activity_Activity::append_comments( $activities, $r['spam'] ); 591 } 592 593 // Pre-fetch data associated with activity users and other objects 594 BP_Activity_Activity::prefetch_object_data( $activities ); 595 596 // Generate action strings 597 $activities = BP_Activity_Activity::generate_action_strings( $activities ); 579 if ( 'ids' === $r['fields'] ) { 580 $activities = array_map( 'intval', $activity_ids ); 581 } else { 582 $activities = self::get_activity_data( $activity_ids ); 583 } 584 } 585 586 if ( 'ids' !== $r['fields'] ) { 587 // Get the fullnames of users so we don't have to query in the loop 588 $activities = self::append_user_fullnames( $activities ); 589 590 // Get activity meta 591 $activity_ids = array(); 592 foreach ( (array) $activities as $activity ) { 593 $activity_ids[] = $activity->id; 594 } 595 596 if ( ! empty( $activity_ids ) && $r['update_meta_cache'] ) { 597 bp_activity_update_meta_cache( $activity_ids ); 598 } 599 600 if ( $activities && $r['display_comments'] ) { 601 $activities = BP_Activity_Activity::append_comments( $activities, $r['spam'] ); 602 } 603 604 // Pre-fetch data associated with activity users and other objects 605 BP_Activity_Activity::prefetch_object_data( $activities ); 606 607 // Generate action strings 608 $activities = BP_Activity_Activity::generate_action_strings( $activities ); 609 } 598 610 599 611 $retval['activities'] = $activities; -
trunk/tests/phpunit/testcases/activity/class.BP_Activity_Activity.php
r9819 r10217 53 53 $meta = bp_activity_get_meta( $activity, 'Paul' ); 54 54 $this->assertSame( '', $meta ); 55 } 56 57 /** 58 * @group get 59 * @group fields 60 * @ticket BP6426 61 */ 62 public function test_get_with_fields_parameter_by_id() { 63 $a = $this->factory->activity->create_many( 3, array( 64 'type' => 'activity_update', 65 ) ); 66 67 $result = BP_Activity_Activity::get( array( 68 'fields' => 'ids', 69 ) ); 70 $this->assertEqualSets( $a, $result['activities'] ); 55 71 } 56 72
Note: See TracChangeset
for help on using the changeset viewer.