Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
12/16/2025 04:29:43 PM (5 months ago)
Author:
espellcaste
Message:

Code Modernization: address the only, so far, two issues related to PHP 8.5.

  • Instances of using null as an array offset.
  • ArrayIterator::__construct(): Using an object as a backing array for ArrayIterator is deprecated.

Reference: https://wiki.php.net/rfc/deprecations_php_8_5\#deprecate_arrayobject_and_arrayiterator_with_objects

Follow-up to [14147].

Props espellcaste.

Closes https://github.com/buddypress/buddypress/pull/425
Fixes #9313 (14.0)

File:
1 edited

Legend:

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

    r13897 r14150  
    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
    26372641                // Recursively find our comment object from the comment tree.
    2638                 $iterator  = new RecursiveArrayIterator( $comments );
    2639                 $recursive = new RecursiveIteratorIterator( $iterator, RecursiveIteratorIterator::SELF_FIRST );
    2640                 foreach ( $recursive as $cid => $cobj ) {
    2641                     // Skip items that are not a comment object.
    2642                     if ( ! is_numeric( $cid ) || ! is_object( $cobj ) ) {
    2643                         continue;
    2644                     }
    2645 
    2646                     // We found the activity comment! Set the depth.
    2647                     if ( $cid === $comment->id && isset( $cobj->depth ) ) {
    2648                         $depth = $cobj->depth;
    2649                         break;
    2650                     }
     2642                $comment_in_tree = BP_Activity_Activity::find_comment_in_tree( $comments, $comment->id );
     2643
     2644                if ( is_object( $comment_in_tree ) && isset( $comment_in_tree->depth ) ) {
     2645                    $depth = $comment_in_tree->depth;
    26512646                }
    26522647            }
Note: See TracChangeset for help on using the changeset viewer.