Skip to:
Content

BuddyPress.org

Changeset 14160


Ignore:
Timestamp:
12/19/2025 07:39:04 PM (8 weeks ago)
Author:
espellcaste
Message:

Return an empty array (instead of false) when BP_Activity_Activity::get_activity_comments has no comments.

Previously, the method would return a boolean false when there was no cached comments. The false had meaning before, see [13312]. But it got changed at [13312].

Props alexanderwbell.

Closes https://github.com/buddypress/buddypress/pull/405
Fixes #9270.

Location:
trunk/src/bp-activity
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-activity/bp-activity-template.php

    r14149 r14160  
    26352635                $comments = BP_Activity_Activity::get_activity_comments( $comment->item_id, 1, constant( 'PHP_INT_MAX' ) );
    26362636
    2637                 if ( ! is_array( $comments ) ) {
    2638                     $comments = [];
    2639                 }
    2640 
    26412637                // Recursively find our comment object from the comment tree.
    26422638                $comment_in_tree = BP_Activity_Activity::find_comment_in_tree( $comments, $comment->id );
  • trunk/src/bp-activity/classes/class-bp-activity-activity.php

    r14149 r14160  
    16151615     * @since 1.2.0
    16161616     *
    1617      * @global wpdb $wpdb WordPress database object.
    1618      *
    16191617     * @param array  $activities Activities to fetch comments for.
    16201618     * @param string $spam       Optional. 'ham_only' (default), 'spam_only' or 'all'.
     
    16521650     * @param string $spam                Optional. 'ham_only' (default), 'spam_only' or 'all'.
    16531651     * @param int    $top_level_parent_id Optional. The id of the root-level parent activity item.
    1654      * @return array|false The updated activities with nested comments. False if no comments are found.
     1652     * @return array The updated activities with nested comments.
    16551653     */
    16561654    public static function get_activity_comments( $activity_id, $left, $right, $spam = 'ham_only', $top_level_parent_id = 0 ) {
     
    16691667        // activity item has no comments.
    16701668        if ( 'none' === $comments_cache ) {
    1671             return false;
     1669            return $comments;
    16721670
    16731671            // A true cache miss.
Note: See TracChangeset for help on using the changeset viewer.