Skip to:
Content

BuddyPress.org

Changeset 14187


Ignore:
Timestamp:
12/30/2025 05:01:23 PM (2 months ago)
Author:
espellcaste
Message:

Activity: officially deprecate the following functions: bp_activity_delete_by_item_id, bp_activity_delete_by_content, bp_activity_delete_by_activity_id, and bp_activity_delete_for_user_by_component.

bp_activity_delete should be used instead and all instances were updated to the use it.

Initially at [5109].

Closes https://github.com/buddypress/buddypress/pull/431
Fixes #6890

Location:
trunk
Files:
8 edited

Legend:

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

    r14077 r14187  
    24712471 * @param int          $post_id ID of the post being unpublished.
    24722472 * @param WP_Post|null $post    Post object.
    2473  * @return bool
    24742473 */
    24752474function bp_activity_post_type_unpublish( $post_id = 0, $post = null ) {
     
    24982497    );
    24992498
    2500     $deleted = bp_activity_delete_by_item_id( $delete_activity_args );
     2499    $deleted = bp_activity_delete( $delete_activity_args );
    25012500
    25022501    /**
     
    25072506     * @param array   $delete_activity_args Array of arguments for activity deletion.
    25082507     * @param WP_Post $post                 Post object.
    2509      * @param bool    $activity             Whether or not the activity was successfully deleted.
     2508     * @param bool    $deleted              Whether or not the activity was successfully deleted.
    25102509     */
    25112510    do_action( 'bp_activity_post_type_unpublished', $delete_activity_args, $post, $deleted );
    2512 
    2513     return $deleted;
    2514 }
    2515 
    2516 /**
    2517  * Create an activity item for a newly posted post type comment.
     2511}
     2512
     2513/**
     2514 * Create an activity item for a newly published post type comment.
    25182515 *
    25192516 * @since 2.5.0
     
    27462743
    27472744    if ( bp_disable_blogforum_comments() ) {
    2748         $deleted = bp_activity_delete_by_item_id( array(
    2749             'item_id'           => get_current_blog_id(),
    2750             'secondary_item_id' => $comment_id,
    2751             'component'         => $activity_comment_object->component_id,
    2752             'type'              => $activity_comment_object->action_id,
    2753             'user_id'           => false,
    2754         ) );
     2745        $deleted = bp_activity_delete(
     2746            array(
     2747                'item_id'           => get_current_blog_id(),
     2748                'secondary_item_id' => $comment_id,
     2749                'component'         => $activity_comment_object->component_id,
     2750                'type'              => $activity_comment_object->action_id,
     2751                'user_id'           => false,
     2752            )
     2753        );
    27552754    }
    27562755
     
    29992998 * array of activity IDs depending on the number deleted.
    30002999 *
    3001  * If you are deleting an activity comment please use bp_activity_delete_comment();
     3000 * If you are deleting an activity comment please use `bp_activity_delete_comment()`;
    30023001 *
    30033002 * @since 1.0.0
     
    30843083}
    30853084
    3086     /**
    3087      * Delete an activity item by activity id.
    3088      *
    3089      * You should use bp_activity_delete() instead.
    3090      *
    3091      * @since 1.1.0
    3092      * @deprecated 1.2.0
    3093      *
    3094      * @param array|string $args See BP_Activity_Activity::get for a
    3095      *                           description of accepted arguments.
    3096      * @return bool
    3097      */
    3098     function bp_activity_delete_by_item_id( $args = '' ) {
    3099 
    3100         $r = bp_parse_args(
    3101             $args,
    3102             array(
    3103                 'item_id'           => false,
    3104                 'component'         => false,
    3105                 'type'              => false,
    3106                 'user_id'           => false,
    3107                 'secondary_item_id' => false,
    3108             )
    3109         );
    3110 
    3111         return bp_activity_delete( $r );
    3112     }
    3113 
    3114     /**
    3115      * Delete an activity item by activity id.
    3116      *
    3117      * @since 1.1.0
    3118      *
    3119      *
    3120      * @param int $activity_id ID of the activity item to be deleted.
    3121      * @return bool
    3122      */
    3123     function bp_activity_delete_by_activity_id( $activity_id ) {
    3124         return bp_activity_delete( array( 'id' => $activity_id ) );
    3125     }
    3126 
    3127     /**
    3128      * Delete an activity item by its content.
    3129      *
    3130      * You should use bp_activity_delete() instead.
    3131      *
    3132      * @since 1.1.0
    3133      * @deprecated 1.2.0
    3134      *
    3135      *
    3136      * @param int    $user_id   The user id.
    3137      * @param string $content   The activity id.
    3138      * @param string $component The activity component.
    3139      * @param string $type      The activity type.
    3140      * @return bool
    3141      */
    3142     function bp_activity_delete_by_content( $user_id, $content, $component, $type ) {
    3143         return bp_activity_delete( array(
    3144             'user_id'   => $user_id,
    3145             'content'   => $content,
    3146             'component' => $component,
    3147             'type'      => $type
    3148         ) );
    3149     }
    3150 
    3151     /**
    3152      * Delete a user's activity for a component.
    3153      *
    3154      * You should use bp_activity_delete() instead.
    3155      *
    3156      * @since 1.1.0
    3157      * @deprecated 1.2.0
    3158      *
    3159      *
    3160      * @param int    $user_id   The user id.
    3161      * @param string $component The activity component.
    3162      * @return bool
    3163      */
    3164     function bp_activity_delete_for_user_by_component( $user_id, $component ) {
    3165         return bp_activity_delete( array(
    3166             'user_id'   => $user_id,
    3167             'component' => $component
    3168         ) );
    3169     }
    3170 
    31713085/**
    31723086 * Delete an activity comment.
     
    32393153    return $deleted;
    32403154}
    3241 
    32423155    /**
    32433156     * Delete an activity comment's children.
  • trunk/src/bp-blogs/bp-blogs-activity.php

    r14077 r14187  
    498498    );
    499499
    500     return bp_activity_delete_by_item_id( $r );
     500    return bp_activity_delete( $r );
    501501}
    502502
  • trunk/src/bp-core/deprecated/15.0.php

    r14074 r14187  
    11<?php
    22/**
    3  * Deprecated Functions
     3 * Deprecated Functions.
    44 *
    55 * @package BuddyPress
     
    1919    echo bp_get_signup_allowed();
    2020}
     21
     22/**
     23 * Delete an activity item by activity id.
     24 *
     25 * @since 1.1.0
     26 * @deprecated 15.0.0
     27 *
     28 * @param array|string $args See BP_Activity_Activity::get for a
     29 *                           description of accepted arguments.
     30 * @return bool
     31 */
     32function bp_activity_delete_by_item_id( $args = '' ) {
     33    _deprecated_function( __FUNCTION__, '15.0.0', 'bp_activity_delete()' );
     34
     35    $r = bp_parse_args(
     36        $args,
     37        array(
     38            'item_id'           => false,
     39            'component'         => false,
     40            'type'              => false,
     41            'user_id'           => false,
     42            'secondary_item_id' => false,
     43        )
     44    );
     45
     46    return bp_activity_delete( $r );
     47}
     48
     49/**
     50 * Delete an activity item by its content.
     51 *
     52 * @since 1.1.0
     53 * @deprecated 15.0.0
     54 *
     55 * @param int    $user_id   The user id.
     56 * @param string $content   The activity id.
     57 * @param string $component The activity component.
     58 * @param string $type      The activity type.
     59 * @return bool
     60 */
     61function bp_activity_delete_by_content( $user_id, $content, $component, $type ) {
     62    _deprecated_function( __FUNCTION__, '15.0.0', 'bp_activity_delete()' );
     63
     64    return bp_activity_delete(
     65        array(
     66            'user_id'   => $user_id,
     67            'content'   => $content,
     68            'component' => $component,
     69            'type'      => $type
     70        )
     71    );
     72}
     73
     74/**
     75 * Delete a user's activity for a component.
     76 *
     77 * @since 1.1.0
     78 * @deprecated 15.0.0
     79 *
     80 * @param int    $user_id   The user id.
     81 * @param string $component The activity component.
     82 * @return bool
     83 */
     84function bp_activity_delete_for_user_by_component( $user_id, $component ) {
     85    _deprecated_function( __FUNCTION__, '15.0.0', 'bp_activity_delete()' );
     86
     87    return bp_activity_delete(
     88        array(
     89            'user_id'   => $user_id,
     90            'component' => $component
     91        )
     92    );
     93}
     94
     95/**
     96 * Delete an activity item by activity id.
     97 *
     98 * @since 1.1.0
     99 * @deprecated 15.0.0
     100 *
     101 * @param int $activity_id ID of the activity item to be deleted.
     102 * @return bool
     103 */
     104function bp_activity_delete_by_activity_id( $activity_id ) {
     105    _deprecated_function( __FUNCTION__, '15.0.0', 'bp_activity_delete()' );
     106
     107    return bp_activity_delete( array( 'id' => $activity_id ) );
     108}
  • trunk/src/bp-friends/bp-friends-activity.php

    r14163 r14187  
    6969 *                           For Friends activity items, this is usually the user ID of one
    7070 *                           of the friends.
    71  *     @type string $type    The 'type' of the activity item (eg
    72  *                           'friendship_accepted').
     71 *     @type string $type    The 'type' of the activity item (e.g.: 'friendship_accepted').
    7372 *     @type int    $user_id ID of the user associated with the activity item.
    7473 * }
     
    7978    }
    8079
    81     bp_activity_delete_by_item_id( array(
    82         'component' => buddypress()->friends->id,
    83         'item_id'   => $args['item_id'],
    84         'type'      => $args['type'],
    85         'user_id'   => $args['user_id'],
    86     ) );
     80    $r = bp_parse_args(
     81        $args,
     82        array(
     83            'component' => buddypress()->friends->id,
     84            'item_id'   => false,
     85            'type'      => false,
     86            'user_id'   => false,
     87        )
     88    );
     89
     90    bp_activity_delete( $r );
    8791}
    8892
  • trunk/src/bp-groups/bp-groups-activity.php

    r14186 r14187  
    861861 */
    862862function bp_groups_delete_group_delete_all_activity( $group_id ) {
    863     if ( bp_is_active( 'activity' ) ) {
    864         bp_activity_delete_by_item_id( array(
     863
     864    // Bail if Activity component is not active.
     865    if ( ! bp_is_active( 'activity' ) ) {
     866        return;
     867    }
     868
     869    bp_activity_delete(
     870        array(
    865871            'item_id'   => $group_id,
    866872            'component' => buddypress()->groups->id
    867         ) );
    868     }
     873        )
     874    );
    869875}
    870876add_action( 'groups_delete_group', 'bp_groups_delete_group_delete_all_activity' );
  • trunk/src/bp-xprofile/bp-xprofile-activity.php

    r13890 r14187  
    117117 * @since 1.0.0
    118118 *
    119  *                            for a specific activity.
    120  *
    121119 * @param array|string $args Containing all variables used after bp_parse_args() call.
    122  * @return bool
    123120 */
    124121function xprofile_delete_activity( $args = '' ) {
     
    126123    // Bail if activity component is not active.
    127124    if ( ! bp_is_active( 'activity' ) ) {
    128         return false;
     125        return;
    129126    }
    130127
     
    139136
    140137    // Delete the activity item.
    141     bp_activity_delete_by_item_id( $r );
     138    bp_activity_delete( $r );
    142139}
    143140
  • trunk/tests/phpunit/testcases/activity/class.BP_Activity_Activity.php

    r13724 r14187  
    976976    public function test_nonexistent_activity_should_have_id_0_after_population() {
    977977        $a = self::factory()->activity->create();
    978         bp_activity_delete_by_activity_id( $a );
     978
     979        bp_activity_delete( array( 'id' => $a ) );
    979980
    980981        $a_obj = new BP_Activity_Activity( $a );
  • trunk/tests/phpunit/testcases/activity/functions.php

    r14070 r14187  
    13941394        $a = self::factory()->activity->create();
    13951395
    1396         bp_activity_delete_by_activity_id( $a );
     1396        bp_activity_delete( array( 'id' => $a ) );
    13971397
    13981398        $c = bp_activity_new_comment( array(
     
    15681568    }
    15691569
    1570     /**
    1571      * @group bp_activity_delete_by_item_id
    1572      */
    15731570    public function test_bp_activity_delete_by_item_id() {
    15741571        $args = array(
     
    15821579        $a = self::factory()->activity->create( $args );
    15831580
    1584         $this->assertTrue( bp_activity_delete_by_item_id( $args ) );
     1581        $this->assertTrue( bp_activity_delete( $args ) );
    15851582
    15861583        $found = bp_activity_get_specific( array(
Note: See TracChangeset for help on using the changeset viewer.