Make WordPress Core


Ignore:
Timestamp:
10/10/2016 06:37:02 AM (10 years ago)
Author:
pento
Message:

General: Restore usage of $wpdb, instead of $this->db.

Hiding the $wpdb global behind a property decreases the readability of the code, as well as causing irrelevant output when dumping an object.

Reverts [38275], [38278], [38279], [38280], [38387].
See #37699.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-roles.php

    r38387 r38768  
    7171
    7272        /**
    73          * @since 4.7.0
    74          * @access protected
    75          * @var wpdb
    76          */
    77         protected $db;
    78 
    79         /**
    8073         * Constructor
    8174         *
    … …  
    8376         */
    8477        public function __construct() {
    85                 $this->db = $GLOBALS['wpdb'];
    86 
    8778                $this->_init();
    8879        }
    … …  
    118109         */
    119110        protected function _init() {
    120                 global $wp_user_roles;
    121                 $this->role_key = $this->db->get_blog_prefix() . 'user_roles';
     111                global $wp_user_roles, $wpdb;
     112
     113                $this->role_key = $wpdb->get_blog_prefix() . 'user_roles';
    122114                if ( ! empty( $wp_user_roles ) ) {
    123115                        $this->roles = $wp_user_roles;
    … …  
    148140         */
    149141        public function reinit() {
     142                global $wpdb;
     143
    150144                // There is no need to reinit if using the wp_user_roles global.
    151145                if ( ! $this->use_db ) {
    … …  
    154148
    155149                // Duplicated from _init() to avoid an extra function call.
    156                 $this->role_key = $this->db->get_blog_prefix() . 'user_roles';
     150                $this->role_key = $wpdb->get_blog_prefix() . 'user_roles';
    157151                $this->roles = get_option( $this->role_key );
    158152                if ( empty( $this->roles ) )
Note: See TracChangeset for help on using the changeset viewer.