Skip to:
Content

BuddyPress.org

Ticket #8554: 8554-1.diff

File 8554-1.diff, 18.9 KB (added by espellcaste, 3 years ago)
  • src/bp-activity/classes/class-bp-activity-activity.php

    diff --git src/bp-activity/classes/class-bp-activity-activity.php src/bp-activity/classes/class-bp-activity-activity.php
    index 6370f72d8..840b90152 100644
    class BP_Activity_Activity { 
    383383                $function_args = func_get_args();
    384384
    385385                // Backward compatibility with old method of passing arguments.
    386                 if ( !is_array( $args ) || count( $function_args ) > 1 ) {
     386                if ( ! is_array( $args ) || count( $function_args ) > 1 ) {
    387387                        _deprecated_argument(
    388388                                __METHOD__,
    389389                                '1.6',
    390390                                sprintf(
    391391                                        /* translators: 1: the name of the method. 2: the name of the file. */
    392                                         __( 'Arguments passed to %1$s should be in an associative array. See the inline documentation at %2$s for more details.', 'buddypress' ),
     392                                        esc_html__( 'Arguments passed to %1$s should be in an associative array. See the inline documentation at %2$s for more details.', 'buddypress' ),
    393393                                        __METHOD__,
    394394                                        __FILE__
    395395                                )
    class BP_Activity_Activity { 
    11551155         * @return array
    11561156         */
    11571157        public static function get_specific( $activity_ids, $max = false, $page = 1, $per_page = 25, $sort = 'DESC', $display_comments = false ) {
    1158                 _deprecated_function( __FUNCTION__, '1.5', 'Use BP_Activity_Activity::get() with the "in" parameter instead.' );
     1158                _deprecated_function(
     1159                        __FUNCTION__,
     1160                        '1.5',
     1161                        'Use BP_Activity_Activity::get() with the "in" parameter instead.'
     1162                );
     1163
    11591164                return BP_Activity_Activity::get( $max, $page, $per_page, $sort, false, false, $display_comments, false, false, $activity_ids );
    11601165        }
    11611166
  • src/bp-friends/bp-friends-functions.php

    diff --git src/bp-friends/bp-friends-functions.php src/bp-friends/bp-friends-functions.php
    index a2a906b5a..c06e9a5ea 100644
    function friends_remove_friend( $initiator_userid, $friend_userid ) { 
    161161function friends_accept_friendship( $friendship_id ) {
    162162
    163163        // Get the friendship data.
    164         $friendship = new BP_Friends_Friendship( $friendship_id, true, false );
     164        $friendship = new BP_Friends_Friendship( $friendship_id, false, false );
    165165
    166166        // Accepting friendship.
    167167        if ( empty( $friendship->is_confirmed ) && BP_Friends_Friendship::accept( $friendship_id ) ) {
    function friends_accept_friendship( $friendship_id ) { 
    196196 * @return bool True on success, false on failure.
    197197 */
    198198function friends_reject_friendship( $friendship_id ) {
    199         $friendship = new BP_Friends_Friendship( $friendship_id, true, false );
     199        $friendship = new BP_Friends_Friendship( $friendship_id, false, false );
    200200
    201201        if ( empty( $friendship->is_confirmed ) && BP_Friends_Friendship::reject( $friendship_id ) ) {
    202202
    function friends_reject_friendship( $friendship_id ) { 
    227227 */
    228228function friends_withdraw_friendship( $initiator_userid, $friend_userid ) {
    229229        $friendship_id = BP_Friends_Friendship::get_friendship_id( $initiator_userid, $friend_userid );
    230         $friendship    = new BP_Friends_Friendship( $friendship_id, true, false );
     230        $friendship    = new BP_Friends_Friendship( $friendship_id, false, false );
    231231
    232232        if ( empty( $friendship->is_confirmed ) && BP_Friends_Friendship::withdraw( $friendship_id ) ) {
    233233
  • src/bp-friends/classes/class-bp-friends-friendship.php

    diff --git src/bp-friends/classes/class-bp-friends-friendship.php src/bp-friends/classes/class-bp-friends-friendship.php
    index 9fa625cc7..75d0c6c8a 100644
    class BP_Friends_Friendship { 
    9797         * Constructor method.
    9898         *
    9999         * @since 1.5.0
     100         * @since 10.0.0 Updated to add deprecated notice for `$is_request`.
    100101         *
    101102         * @param int|null $id                      Optional. The ID of an existing friendship.
    102103         * @param bool     $is_request              Deprecated.
    103          * @param bool     $populate_friend_details True if friend details should be queried.
     104         * @param bool     $populate_friend_details Optional. True if friend details should be queried.
    104105         */
    105106        public function __construct( $id = null, $is_request = false, $populate_friend_details = true ) {
     107
     108                if ( false !== $is_request ) {
     109                        _deprecated_argument(
     110                                __METHOD__,
     111                                '1.5.0',
     112                                sprintf(
     113                                        /* translators: 1: the name of the method. 2: the name of the file. */
     114                                        esc_html__( '%1$s no longer accepts $is_request. See the inline documentation at %2$s for more details.', 'buddypress' ),
     115                                        __METHOD__,
     116                                        __FILE__
     117                                )
     118                        );
     119                }
     120
    106121                $this->is_request = $is_request;
    107122
    108                 if ( !empty( $id ) ) {
     123                if ( ! empty( $id ) ) {
    109124                        $this->id                      = (int) $id;
    110125                        $this->populate_friend_details = $populate_friend_details;
    111126                        $this->populate( $this->id );
  • src/bp-groups/classes/class-bp-groups-group.php

    diff --git src/bp-groups/classes/class-bp-groups-group.php src/bp-groups/classes/class-bp-groups-group.php
    index f06ec8055..15dc4d592 100644
    class BP_Groups_Group { 
    179179        /**
    180180         * Raw arguments passed to the constructor.
    181181         *
     182         * Not currently used by BuddyPress.
     183         *
    182184         * @since 2.0.0
    183185         * @var array
    184186         */
    class BP_Groups_Group { 
    197199         * }
    198200         */
    199201        public function __construct( $id = null, $args = array() ) {
    200                 if ( !empty( $id ) ) {
     202
     203                // Deprecated notice about $args.
     204                if ( ! empty( $args ) ) {
     205                        _deprecated_argument(
     206                                __METHOD__,
     207                                '1.6.0',
     208                                sprintf(
     209                                        /* translators: 1: the name of the method. 2: the name of the file. */
     210                                        esc_html__( '%1$s no longer accepts arguments. See the inline documentation at %2$s for more details.', 'buddypress' ),
     211                                        __METHOD__,
     212                                        __FILE__
     213                                )
     214                        );
     215                }
     216
     217                if ( ! empty( $id ) ) {
    201218                        $this->id = (int) $id;
    202219                        $this->populate();
    203220                }
    class BP_Groups_Group { 
    671688         * Get whether a group exists for a given slug.
    672689         *
    673690         * @since 1.6.0
     691         * @since 10.0.0 Updated to add the deprecated notice.
    674692         *
    675693         * @param string      $slug       Slug to check.
    676694         * @param string|bool $table_name Deprecated.
    677          * @return int|null Group ID if found; null if not.
     695         * @return int|null|bool False if empty slug, group ID if found; `null` if not.
    678696         */
    679697        public static function group_exists( $slug, $table_name = false ) {
    680                 global $wpdb;
     698
     699                if ( false !== $table_name ) {
     700                        _deprecated_argument(
     701                                __METHOD__,
     702                                '1.6.0',
     703                                sprintf(
     704                                        /* translators: 1: the name of the method. 2: the name of the file. */
     705                                        esc_html__( '%1$s no longer accepts a table name argument. See the inline documentation at %2$s for more details.', 'buddypress' ),
     706                                        __METHOD__,
     707                                        __FILE__
     708                                )
     709                        );
     710                }
    681711
    682712                if ( empty( $slug ) ) {
    683713                        return false;
    684714                }
    685715
    686                 $args = array(
    687                         'slug'               => $slug,
    688                         'per_page'           => 1,
    689                         'page'               => 1,
    690                         'update_meta_cache'  => false,
    691                         'show_hidden'        => true,
     716                $groups = self::get(
     717                        array(
     718                                'slug'              => $slug,
     719                                'per_page'          => 1,
     720                                'page'              => 1,
     721                                'update_meta_cache' => false,
     722                                'show_hidden'       => true,
     723                        )
    692724                );
    693725
    694                 $groups = BP_Groups_Group::get( $args );
    695 
    696726                $group_id = null;
    697727                if ( $groups['groups'] ) {
    698728                        $group_id = current( $groups['groups'] )->id;
    class BP_Groups_Group { 
    709739         * @since 1.6.0
    710740         *
    711741         * @param string $slug See {@link BP_Groups_Group::group_exists()}.
    712          * @return int|null See {@link BP_Groups_Group::group_exists()}.
     742         * @return int|null|bool See {@link BP_Groups_Group::group_exists()}.
    713743         */
    714744        public static function get_id_from_slug( $slug ) {
    715                 return BP_Groups_Group::group_exists( $slug );
     745                return self::group_exists( $slug );
    716746        }
    717747
    718748        /**
    class BP_Groups_Group { 
    10551085
    10561086                // Backward compatibility with old method of passing arguments.
    10571087                if ( ! is_array( $args ) || count( $function_args ) > 1 ) {
    1058                         _deprecated_argument( __METHOD__, '1.7', sprintf( __( 'Arguments passed to %1$s should be in an associative array. See the inline documentation at %2$s for more details.', 'buddypress' ), __METHOD__, __FILE__ ) );
     1088                        _deprecated_argument(
     1089                                __METHOD__,
     1090                                '1.7',
     1091                                sprintf(
     1092                                        /* translators: 1: the name of the method. 2: the name of the file. */
     1093                                        esc_html__( 'Arguments passed to %1$s should be in an associative array. See the inline documentation at %2$s for more details.', 'buddypress' ),
     1094                                        __METHOD__,
     1095                                        __FILE__
     1096                                )
     1097                        );
    10591098
    10601099                        $old_args_keys = array(
    10611100                                0 => 'type',
    class BP_Groups_Group { 
    15361575         * }
    15371576         */
    15381577        public static function get_by_letter( $letter, $limit = null, $page = null, $populate_extras = true, $exclude = false ) {
    1539                 global $wpdb;
    15401578
    1541                 $pag_sql = $hidden_sql = $exclude_sql = '';
     1579                if ( true !== $populate_extras ) {
     1580                        _deprecated_argument(
     1581                                __METHOD__,
     1582                                '1.6.0',
     1583                                sprintf(
     1584                                        /* translators: 1: the name of the method. 2: the name of the file. */
     1585                                        esc_html__( '%1$s no longer accepts setting $populate_extras. See the inline documentation at %2$s for more details.', 'buddypress' ),
     1586                                        __METHOD__,
     1587                                        __FILE__
     1588                                )
     1589                        );
     1590                }
    15421591
    15431592                // Multibyte compliance.
    15441593                if ( function_exists( 'mb_strlen' ) ) {
    class BP_Groups_Group { 
    15511600                        }
    15521601                }
    15531602
    1554                 $args = array(
    1555                         'per_page'       => $limit,
    1556                         'page'           => $page,
    1557                         'search_terms'   => $letter . '*',
    1558                         'search_columns' => array( 'name' ),
    1559                         'exclude'        => $exclude,
     1603                return self::get(
     1604                        array(
     1605                                'per_page'       => $limit,
     1606                                'page'           => $page,
     1607                                'search_terms'   => $letter . '*',
     1608                                'search_columns' => array( 'name' ),
     1609                                'exclude'        => $exclude,
     1610                        )
    15601611                );
    1561 
    1562                 return BP_Groups_Group::get( $args );
    15631612        }
    15641613
    15651614        /**
    class BP_Groups_Group { 
    15681617         * Use BP_Groups_Group::get() with 'type' = 'random' instead.
    15691618         *
    15701619         * @since 1.6.0
     1620         * @since 10.0.0 Deprecate the `$populate_extras` arg.
    15711621         *
    15721622         * @param int|null          $limit           Optional. The max number of results to return.
    15731623         *                                           Default: null (no limit).
    class BP_Groups_Group { 
    15771627         *                                           those of which the specified user is a member.
    15781628         * @param string|bool       $search_terms    Optional. Limit groups to those whose name
    15791629         *                                           or description field contain the search string.
    1580          * @param bool              $populate_extras Optional. Whether to fetch extra
    1581          *                                           information about the groups. Default: true.
     1630         * @param bool              $populate_extras Deprecated.
    15821631         * @param string|array|bool $exclude         Optional. Array or comma-separated list of group
    15831632         *                                           IDs to exclude from results.
    15841633         * @return array {
    class BP_Groups_Group { 
    15891638         * }
    15901639         */
    15911640        public static function get_random( $limit = null, $page = null, $user_id = 0, $search_terms = false, $populate_extras = true, $exclude = false ) {
    1592                 $args = array(
    1593                         'type'               => 'random',
    1594                         'per_page'           => $limit,
    1595                         'page'               => $page,
    1596                         'user_id'            => $user_id,
    1597                         'search_terms'       => $search_terms,
    1598                         'exclude'            => $exclude,
    1599                 );
    16001641
    1601                 return BP_Groups_Group::get( $args );
     1642                if ( true !== $populate_extras ) {
     1643                        _deprecated_argument(
     1644                                __METHOD__,
     1645                                '10.0.0',
     1646                                sprintf(
     1647                                        /* translators: 1: the name of the method. 2: the name of the file. */
     1648                                        esc_html__( '%1$s no longer accepts setting $populate_extras. See the inline documentation at %2$s for more details.', 'buddypress' ),
     1649                                        __METHOD__,
     1650                                        __FILE__
     1651                                )
     1652                        );
     1653                }
     1654
     1655                return self::get(
     1656                        array(
     1657                                'type'         => 'random',
     1658                                'per_page'     => $limit,
     1659                                'page'         => $page,
     1660                                'user_id'      => $user_id,
     1661                                'search_terms' => $search_terms,
     1662                                'exclude'      => $exclude,
     1663                        )
     1664                );
    16021665        }
    16031666
    16041667        /**
  • src/bp-messages/classes/class-bp-messages-thread.php

    diff --git src/bp-messages/classes/class-bp-messages-thread.php src/bp-messages/classes/class-bp-messages-thread.php
    index 8a87d8faa..805353582 100644
    class BP_Messages_Thread { 
    449449
    450450                // Backward compatibility with old method of passing arguments.
    451451                if ( ! is_array( $args ) || count( $function_args ) > 1 ) {
    452                         _deprecated_argument( __METHOD__, '2.2.0', sprintf( __( 'Arguments passed to %1$s should be in an associative array. See the inline documentation at %2$s for more details.', 'buddypress' ), __METHOD__, __FILE__ ) );
     452                        _deprecated_argument(
     453                                __METHOD__,
     454                                '2.2.0',
     455                                sprintf(
     456                                        /* translators: 1: the name of the method. 2: the name of the file. */
     457                                        esc_html__( 'Arguments passed to %1$s should be in an associative array. See the inline documentation at %2$s for more details.', 'buddypress' ),
     458                                        __METHOD__,
     459                                        __FILE__
     460                                )
     461                        );
    453462
    454463                        $old_args_keys = array(
    455464                                0 => 'user_id',
  • tests/phpunit/testcases/friends/class-bp-friends-friendship.php

    diff --git tests/phpunit/testcases/friends/class-bp-friends-friendship.php tests/phpunit/testcases/friends/class-bp-friends-friendship.php
    index de50557d4..dbfaa07c6 100644
     
    44 * @group friends
    55 */
    66class BP_Tests_BP_Friends_Friendship_TestCases extends BP_UnitTestCase {
     7
     8        /** __construct()  ***************************************************/
     9
     10        /**
     11         * @group __construct
     12         */
     13        public function test_non_existent_friendship() {
     14                $friendship = new BP_Friends_Friendship( 123456789 );
     15                $this->assertSame( 0, $friendship->id );
     16        }
     17
     18        /**
     19         * @group __construct
     20         * @expectedDeprecated BP_Friends_Friendship::__construct
     21         */
     22        public function test_deprecated_arg() {
     23                $friendship = new BP_Friends_Friendship( 123456789, true );
     24                $this->assertSame( 0, $friendship->id );
     25        }
     26
    727        public function test_search_friends() {
    828                $u1 = self::factory()->user->create();
    929                $u2 = self::factory()->user->create();
  • tests/phpunit/testcases/groups/class-bp-groups-group.php

    diff --git tests/phpunit/testcases/groups/class-bp-groups-group.php tests/phpunit/testcases/groups/class-bp-groups-group.php
    index b6f0f00ad..d1dbd1d4b 100644
    class BP_Tests_BP_Groups_Group_TestCases extends BP_UnitTestCase { 
    1515                $this->assertSame( 0, $group->id );
    1616        }
    1717
     18        /**
     19         * @group __construct
     20         * @expectedDeprecated BP_Groups_Group::__construct
     21         */
     22        public function test_deprecated_arg() {
     23                $group = new BP_Groups_Group( 123456789, array( 'populate_extras' => true ) );
     24                $this->assertSame( 0, $group->id );
     25        }
     26
    1827        /** get() ************************************************************/
    1928
     29        /**
     30         * @group get
     31         */
     32        public function test_get_group_id_with_slug() {
     33                $slug     = 'group-test';
     34                $g1       = self::factory()->group->create( array( 'slug' => $slug ) );
     35                $group_id = BP_Groups_Group::group_exists( $slug );
     36
     37                $this->assertSame( $g1, $group_id );
     38        }
     39
     40        /**
     41         * @group get
     42         */
     43        public function test_get_group_id_with_empty_slug() {
     44                $this->assertFalse( BP_Groups_Group::group_exists( '' ) );
     45        }
     46
     47        /**
     48         * @group get
     49         */
     50        public function test_get_group_id_from_slug_with_empty_slug() {
     51                $this->assertFalse( BP_Groups_Group::get_id_from_slug( '' ) );
     52        }
     53
     54        /**
     55         * @group get
     56         */
     57        public function test_get_group_id_from_slug() {
     58                $slug     = 'group-test';
     59                $g1       = self::factory()->group->create( array( 'slug' => $slug ) );
     60                $group_id = BP_Groups_Group::get_id_from_slug( $slug );
     61
     62                $this->assertSame( $g1, $group_id );
     63        }
     64
     65        /**
     66         * @group get
     67         * @expectedDeprecated BP_Groups_Group::group_exists
     68         */
     69        public function test_get_group_with_slug_with_deprecated_args() {
     70                $slug     = 'group-test';
     71                $g1       = self::factory()->group->create( array( 'slug' => $slug ) );
     72                $group_id = BP_Groups_Group::group_exists( $slug, 'random-name' );
     73
     74                $this->assertSame( $g1, $group_id );
     75        }
     76
    2077        /**
    2178         * @group get
    2279         */
    class BP_Tests_BP_Groups_Group_TestCases extends BP_UnitTestCase { 
    11431200                $g2 = self::factory()->group->create();
    11441201
    11451202                $groups = BP_Groups_Group::search_groups( "'tis " );
     1203                $found  = wp_list_pluck( $groups['groups'], 'group_id' );
    11461204
    1147                 $found = wp_list_pluck( $groups['groups'], 'group_id' );
     1205                $this->assertEquals( array( $g1 ), $found );
     1206                $this->assertNotContains( $g2, $found );
     1207        }
     1208
     1209        /**
     1210         * @expectedDeprecated BP_Groups_Group::get_by_letter
     1211         */
     1212        public function test_get_by_letter_with_deprecated_arg() {
     1213                $g1 = self::factory()->group->create( array(
     1214                        'name'        => 'Awesome Cool Group',
     1215                        'description' => 'Neat',
     1216                ) );
     1217                $g2 = self::factory()->group->create();
     1218
     1219                $groups = BP_Groups_Group::get_by_letter( 'A', null, null, false );
     1220                $found  = wp_list_pluck( $groups['groups'], 'id' );
    11481221
    11491222                $this->assertEquals( array( $g1 ), $found );
     1223                $this->assertNotContains( $g2, $found );
    11501224        }
    11511225
    11521226        public function test_get_by_letter_typical_use() {
    11531227                $g1 = self::factory()->group->create( array(
    1154                         'name' => 'Awesome Cool Group',
     1228                        'name'        => 'Awesome Cool Group',
    11551229                        'description' => 'Neat',
    11561230                ) );
    1157                 $g2 = self::factory()->group->create( array(
    1158                         'name' => 'Babylon Kong',
    1159                         'description' => 'Awesome',
    1160                 ) );
     1231                $g2 = self::factory()->group->create();
    11611232
    11621233                $groups = BP_Groups_Group::get_by_letter( 'A' );
    1163 
    1164                 $found = wp_list_pluck( $groups['groups'], 'id' );
     1234                $found  = wp_list_pluck( $groups['groups'], 'id' );
    11651235
    11661236                $this->assertEquals( array( $g1 ), $found );
    1167 
     1237                $this->assertNotContains( $g2, $found );
    11681238        }
    11691239
    11701240        public function test_get_by_letter_with_exclude() {
    class BP_Tests_BP_Groups_Group_TestCases extends BP_UnitTestCase { 
    11781248                ) );
    11791249
    11801250                $groups = BP_Groups_Group::get_by_letter( 'A', null, null, true, array( $g1, 'stringthatshouldberemoved' ) );
    1181 
    1182                 $found = wp_list_pluck( $groups['groups'], 'id' );
     1251                $found  = wp_list_pluck( $groups['groups'], 'id' );
    11831252
    11841253                $this->assertEquals( array( $g2 ), $found );
    11851254
    class BP_Tests_BP_Groups_Group_TestCases extends BP_UnitTestCase { 
    12091278                );
    12101279        }
    12111280
     1281        /**
     1282         * @expectedDeprecated BP_Groups_Group::get_random
     1283         */
     1284        public function test_get_random_with_deprecated_arg() {
     1285                $g1 = self::factory()->group->create();
     1286                $g2 = self::factory()->group->create();
     1287
     1288                // There are only two groups, so excluding one should give us the other
     1289                $groups = BP_Groups_Group::get_random( null, null, 0, false, false, array( $g1, 'ignore this' ) );
     1290                $found  = wp_list_pluck( $groups['groups'], 'id' );
     1291
     1292                $this->assertEquals( array( $g2 ), $found );
     1293        }
     1294
    12121295        public function test_get_random_with_exclude() {
    12131296                $g1 = self::factory()->group->create();
    12141297                $g2 = self::factory()->group->create();
    class BP_Tests_BP_Groups_Group_TestCases extends BP_UnitTestCase { 
    12311314
    12321315                // Only one group will match, so the random part doesn't matter
    12331316                $groups = BP_Groups_Group::get_random( null, null, 0, 'daci' );
    1234 
    1235                 $found = wp_list_pluck( $groups['groups'], 'id' );
     1317                $found  = wp_list_pluck( $groups['groups'], 'id' );
    12361318
    12371319                $this->assertEquals( array( $g1 ), $found );
     1320                $this->assertNotContains( $g2, $found );
    12381321        }
    12391322
    12401323        /**