diff --git src/bp-activity/classes/class-bp-activity-activity.php src/bp-activity/classes/class-bp-activity-activity.php
index 5081009..a03ebb1 100644
|
|
class BP_Activity_Activity { |
272 | 272 | * in no pagination. Default: 1. |
273 | 273 | * @type int|bool $per_page Number of results per page. Default: 25. |
274 | 274 | * @type int|bool $max Maximum number of results to return. Default: false (unlimited). |
| 275 | * @type string $fields Activity fields to return. Pass 'ids' to get only the activity IDs. |
| 276 | * 'all' returns full activity objects. |
275 | 277 | * @type string $sort ASC or DESC. Default: 'DESC'. |
276 | 278 | * @type array $exclude Array of activity IDs to exclude. Default: false. |
277 | 279 | * @type array $in Array of ids to limit query by (IN). Default: false. |
… |
… |
class BP_Activity_Activity { |
323 | 325 | 'page' => 1, // The current page |
324 | 326 | 'per_page' => 25, // Activity items per page |
325 | 327 | 'max' => false, // Max number of items to return |
| 328 | 'fields' => 'all', |
326 | 329 | 'sort' => 'DESC', // ASC or DESC |
327 | 330 | 'exclude' => false, // Array of ids to exclude |
328 | 331 | 'in' => false, // Array of ids to limit query by (IN) |
… |
… |
class BP_Activity_Activity { |
570 | 573 | array_pop( $activity_ids ); |
571 | 574 | } |
572 | 575 | |
573 | | $activities = self::get_activity_data( $activity_ids ); |
| 576 | if ( 'ids' === $r['fields'] ) { |
| 577 | $activities = array_map( 'intval', $activity_ids ); |
| 578 | } else { |
| 579 | $activities = self::get_activity_data( $activity_ids ); |
| 580 | } |
574 | 581 | } |
575 | 582 | |
576 | | // Get the fullnames of users so we don't have to query in the loop |
577 | | $activities = self::append_user_fullnames( $activities ); |
| 583 | if ( 'ids' !== $r['fields'] ) { |
| 584 | // Get the fullnames of users so we don't have to query in the loop |
| 585 | $activities = self::append_user_fullnames( $activities ); |
578 | 586 | |
579 | | // Get activity meta |
580 | | $activity_ids = array(); |
581 | | foreach ( (array) $activities as $activity ) { |
582 | | $activity_ids[] = $activity->id; |
583 | | } |
| 587 | // Get activity meta |
| 588 | $activity_ids = array(); |
| 589 | foreach ( (array) $activities as $activity ) { |
| 590 | $activity_ids[] = $activity->id; |
| 591 | } |
584 | 592 | |
585 | | if ( ! empty( $activity_ids ) && $r['update_meta_cache'] ) { |
586 | | bp_activity_update_meta_cache( $activity_ids ); |
587 | | } |
| 593 | if ( ! empty( $activity_ids ) && $r['update_meta_cache'] ) { |
| 594 | bp_activity_update_meta_cache( $activity_ids ); |
| 595 | } |
588 | 596 | |
589 | | if ( $activities && $r['display_comments'] ) { |
590 | | $activities = BP_Activity_Activity::append_comments( $activities, $r['spam'] ); |
591 | | } |
| 597 | if ( $activities && $r['display_comments'] ) { |
| 598 | $activities = BP_Activity_Activity::append_comments( $activities, $r['spam'] ); |
| 599 | } |
592 | 600 | |
593 | | // Pre-fetch data associated with activity users and other objects |
594 | | BP_Activity_Activity::prefetch_object_data( $activities ); |
| 601 | // Pre-fetch data associated with activity users and other objects |
| 602 | BP_Activity_Activity::prefetch_object_data( $activities ); |
595 | 603 | |
596 | | // Generate action strings |
597 | | $activities = BP_Activity_Activity::generate_action_strings( $activities ); |
| 604 | // Generate action strings |
| 605 | $activities = BP_Activity_Activity::generate_action_strings( $activities ); |
| 606 | } |
598 | 607 | |
599 | 608 | $retval['activities'] = $activities; |
600 | 609 | |
diff --git tests/phpunit/testcases/activity/class.BP_Activity_Activity.php tests/phpunit/testcases/activity/class.BP_Activity_Activity.php
index 6a52f4e..3da21f1 100644
|
|
class BP_Tests_Activity_Class extends BP_UnitTestCase { |
56 | 56 | |
57 | 57 | /** |
58 | 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'] ); |
| 71 | } |
| 72 | |
| 73 | /** |
| 74 | * @group get |
59 | 75 | */ |
60 | 76 | public function test_hide_all_for_user() { |
61 | 77 | $activity = $this->factory->activity->create( array( |