Make WordPress Core

Ticket #19615: 19615.3.diff

File 19615.3.diff, 3.6 KB (added by swissspidy, 9 years ago)
  • src/wp-includes/pluggable-deprecated.php

    diff --git src/wp-includes/pluggable-deprecated.php src/wp-includes/pluggable-deprecated.php
    index 39fcd49..77690bf 100644
    function set_current_user($id, $name = '') { 
    3535}
    3636endif;
    3737
     38if ( !function_exists('get_currentuserinfo') ) :
     39/**
     40 * Populate global variables with information about the currently logged in user.
     41 *
     42 * @since 0.71
     43 * @deprecated 4.5.0 Use wp_get_current_user()
     44 * @see wp_get_current_user()
     45 *
     46 * @return bool|WP_User False on XMLRPC Request and invalid auth cookie, WP_User instance otherwise.
     47 */
     48function get_currentuserinfo() {
     49        _deprecated_function( __FUNCTION__, '4.5', 'wp_get_current_user()' );
     50
     51        return wp_get_current_user();
     52}
     53endif;
     54
    3855if ( !function_exists('get_userdatabylogin') ) :
    3956/**
    4057 * Retrieve user info by login name.
    if ( ! class_exists( 'wp_atom_server', false ) ) { 
    188205                        _deprecated_function( __CLASS__ . '::' . $name, '3.5', 'the Atom Publishing Protocol plugin' );
    189206                }
    190207        }
    191 }
    192  No newline at end of file
     208}
  • src/wp-includes/pluggable.php

    diff --git src/wp-includes/pluggable.php src/wp-includes/pluggable.php
    index 5b441d8..02b3f75 100644
    if ( !function_exists('wp_get_current_user') ) : 
    5454/**
    5555 * Retrieve the current user object.
    5656 *
    57  * @since 2.0.3
    58  *
    59  * @global WP_User $current_user
    60  *
    61  * @return WP_User Current user WP_User object
    62  */
    63 function wp_get_current_user() {
    64         global $current_user;
    65 
    66         get_currentuserinfo();
    67 
    68         return $current_user;
    69 }
    70 endif;
    71 
    72 if ( !function_exists('get_currentuserinfo') ) :
    73 /**
    74  * Populate global variables with information about the currently logged in user.
    75  *
    7657 * Will set the current user, if the current user is not set. The current user
    7758 * will be set to the logged-in person. If no user is logged-in, then it will
    7859 * set the current user to 0, which is invalid and won't have any permissions.
    7960 *
    80  * @since 0.71
     61 * @since 2.0.3
    8162 *
    82  * @global WP_User $current_user Checks if the current user is set
     63 * @global WP_User $current_user Checks if the current user is set.
    8364 *
    84  * @return false|void False on XML-RPC Request and invalid auth cookie.
     65 * @return bool|WP_User WP_User instance on success, false on XMLRPC Request and invalid auth cookie.
    8566 */
    86 function get_currentuserinfo() {
     67function wp_get_current_user() {
    8768        global $current_user;
    8869
    8970        if ( ! empty( $current_user ) ) {
    90                 if ( $current_user instanceof WP_User )
    91                         return;
     71                if ( $current_user instanceof WP_User ) {
     72                        return $current_user;
     73                }
    9274
    9375                // Upgrade stdClass to WP_User
    9476                if ( is_object( $current_user ) && isset( $current_user->ID ) ) {
    9577                        $cur_id = $current_user->ID;
    9678                        $current_user = null;
    9779                        wp_set_current_user( $cur_id );
    98                         return;
     80                        return $current_user;
    9981                }
    10082
    10183                // $current_user has a junk value. Force to WP_User with ID 0.
    function get_currentuserinfo() { 
    129111        }
    130112
    131113        wp_set_current_user( $user_id );
     114
     115        return $current_user;
    132116}
    133117endif;
    134118
  • tests/phpunit/tests/pluggable.php

    diff --git tests/phpunit/tests/pluggable.php tests/phpunit/tests/pluggable.php
    index a757a60..82c6ab1 100644
    class Tests_Pluggable extends WP_UnitTestCase { 
    127127                        // wp-includes/pluggable.php:
    128128                        'wp_set_current_user'             => array( 'id', 'name' => '' ),
    129129                        'wp_get_current_user'             => array(),
    130                         'get_currentuserinfo'             => array(),
    131130                        'get_userdata'                    => array( 'user_id' ),
    132131                        'get_user_by'                     => array( 'field', 'value' ),
    133132                        'cache_users'                     => array( 'user_ids' ),