Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
08/22/2021 03:16:06 AM (3 years ago)
Author:
espellcaste
Message:

Marking deprecated query classes, their methods, arguments as deprecated in the BP_Friends_Friendship and BP_Friends_Friendship classes.

Props imath

Fixes #8554 (trunk)

File:
1 edited

Legend:

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

    r12731 r13086  
    180180     * Raw arguments passed to the constructor.
    181181     *
     182     * Not currently used by BuddyPress.
     183     *
    182184     * @since 2.0.0
    183185     * @var array
     
    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();
     
    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 ) ) {
     
    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        );
    693 
    694         $groups = BP_Groups_Group::get( $args );
    695725
    696726        $group_id = null;
     
    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
     
    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(
     
    15371576     */
    15381577    public static function get_by_letter( $letter, $limit = null, $page = null, $populate_extras = true, $exclude = false ) {
    1539         global $wpdb;
    1540 
    1541         $pag_sql = $hidden_sql = $exclude_sql = '';
     1578
     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.
     
    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
     
    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.
     
    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.
     
    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,
     1641
     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            )
    15991664        );
    1600 
    1601         return BP_Groups_Group::get( $args );
    16021665    }
    16031666
Note: See TracChangeset for help on using the changeset viewer.