Skip to:
Content

BuddyPress.org

Changeset 13312


Ignore:
Timestamp:
08/13/2022 08:21:06 AM (4 years ago)
Author:
imath
Message:

Avoid various PHP 8.1 deprecated notices

Here are the treated deprecated notices:

  • ctype_digit() Argument of type int will be interpreted as string in the future.
  • Automatic conversion of false to array.
  • Passing null to strtotime() $datetime parameter.

Props renatonascalves, rafiahmedd

See #8649

Location:
trunk/src
Files:
8 edited

Legend:

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

    r13184 r13312  
    12411241                );
    12421242
    1243                 $where_args = false;
     1243                $where_args = array();
    12441244
    12451245                if ( ! empty( $r['user_id'] ) ) {
     
    15681568                }
    15691569
    1570                 $comments = wp_cache_get( $activity_id, 'bp_activity_comments' );
     1570                $comments       = array();
     1571                $comments_cache = wp_cache_get( $activity_id, 'bp_activity_comments' );
    15711572
    15721573                // We store the string 'none' to cache the fact that the
    15731574                // activity item has no comments.
    1574                 if ( 'none' === $comments ) {
    1575                         $comments = false;
     1575                if ( 'none' === $comments_cache ) {
     1576                        return false;
    15761577
    15771578                        // A true cache miss.
    1578                 } elseif ( empty( $comments ) ) {
     1579                } elseif ( empty( $comments_cache ) ) {
    15791580
    15801581                        $bp = buddypress();
     
    16901691                        }
    16911692
    1692                         // If we cache a value of false, it'll count as a cache
     1693                        // If we cache an empty array, it'll count as a cache
    16931694                        // miss the next time the activity comments are fetched.
    16941695                        // Storing the string 'none' is a hack workaround to
    16951696                        // avoid unnecessary queries.
    1696                         if ( false === $comments ) {
     1697                        if ( ! $comments ) {
    16971698                                $cache_value = 'none';
    16981699                        } else {
     
    17011702
    17021703                        wp_cache_set( $activity_id, $cache_value, 'bp_activity_comments' );
     1704                } else {
     1705                        $comments = (array) $comments_cache;
    17031706                }
    17041707
  • trunk/src/bp-core/bp-core-avatars.php

    r13311 r13312  
    811811
    812812                /** This filter is documented in bp-core/bp-core-avatars.php */
    813                 $item_id = apply_filters( 'bp_core_avatar_item_id', $args['item_id'], $args['object'] );
     813                $item_id = (int) apply_filters( 'bp_core_avatar_item_id', $args['item_id'], $args['object'] );
    814814        } else {
    815                 $item_id = $args['item_id'];
    816         }
    817 
    818         if ( $item_id && ( ctype_digit( $item_id ) || is_int( $item_id ) ) ) {
    819                 $item_id = (int) $item_id;
    820         } else {
     815                $item_id = (int) str_replace( '.', '', $args['item_id'] );
     816        }
     817
     818        if ( ! $item_id ) {
    821819                return false;
    822820        }
  • trunk/src/bp-core/bp-core-functions.php

    r13304 r13312  
    34013401        }
    34023402
    3403         $db_types = wp_cache_get( $taxonomy, 'bp_object_terms' );
     3403        $db_types = (array) wp_cache_get( $taxonomy, 'bp_object_terms' );
    34043404
    34053405        if ( ! $db_types ) {
  • trunk/src/bp-groups/bp-groups-activity.php

    r13108 r13312  
    890890
    891891        // Check the time period, and maybe delete their recent group activity.
    892         if ( time() <= strtotime( '+5 minutes', (int) strtotime( $membership->date_modified ) ) ) {
     892        if ( $membership->date_modified && time() <= strtotime( '+5 minutes', (int) strtotime( $membership->date_modified ) ) ) {
    893893                bp_activity_delete( array(
    894894                        'component' => buddypress()->groups->id,
  • trunk/src/bp-groups/bp-groups-functions.php

    r13309 r13312  
    29702970        }
    29712971
    2972         $types = wp_filter_object_list( $types, $args, $operator );
     2972        $types = array_filter( wp_filter_object_list( $types, $args, $operator ) );
    29732973
    29742974        /**
     
    29842984         * @param string $operator  'or' to match any of $args, 'and' to require all.
    29852985         */
    2986         $types = apply_filters( 'bp_groups_get_group_types', $types, $args, $operator );
    2987 
    2988         if ( 'names' === $output ) {
     2986        $types = (array) apply_filters( 'bp_groups_get_group_types', $types, $args, $operator );
     2987
     2988        if ( $types && 'names' === $output ) {
    29892989                $types = wp_list_pluck( $types, 'name' );
    29902990        }
  • trunk/src/bp-members/bp-members-functions.php

    r13309 r13312  
    30103010        }
    30113011
    3012         $types = wp_filter_object_list( $types, $args, $operator );
     3012        $types = array_filter( wp_filter_object_list( $types, $args, $operator ) );
    30133013
    30143014        /**
     
    30243024         * @param string $operator  'or' to match any of $args, 'and' to require all.
    30253025         */
    3026         $types = apply_filters( 'bp_get_member_types', $types, $args, $operator );
    3027 
    3028         if ( 'names' === $output ) {
     3026        $types = (array) apply_filters( 'bp_get_member_types', $types, $args, $operator );
     3027
     3028        if ( $types && 'names' === $output ) {
    30293029                $types = wp_list_pluck( $types, 'name' );
    30303030        }
  • trunk/src/bp-messages/classes/class-bp-messages-message.php

    r13096 r13312  
    6161         * Message recipients.
    6262         *
    63          * @var bool|array
    64          */
    65         public $recipients = false;
     63         * @var array
     64         */
     65        public $recipients = array();
    6666
    6767        /**
  • trunk/src/bp-templates/bp-nouveau/includes/functions.php

    r13170 r13312  
    245245         * from the component ID.
    246246         */
    247         $current_component_id = bp_core_get_active_components( array( 'slug' => bp_current_component() ) );
     247        $current_component_id = bp_core_get_active_components( array( 'id' => bp_current_component() ) );
    248248        if ( $current_component_id && 1 === count( $current_component_id ) ) {
    249249                $current_component_id = reset( $current_component_id );
Note: See TracChangeset for help on using the changeset viewer.