Make WordPress Core

Ticket #38630: 38630.2.diff

File 38630.2.diff, 3.1 KB (added by flixos90, 8 years ago)
  • src/wp-includes/class-wp-site.php

     
    1515 *
    1616 * @since 4.5.0
    1717 *
    18  * @property int    $id
    19  * @property int    $network_id
    2018 * @property string $blogname
    2119 * @property string $siteurl
    2220 * @property int    $post_count
     
    2725        /**
    2826         * Site ID.
    2927         *
    30          * A numeric string, for compatibility reasons.
    31          *
    32          * @since 4.5.0
     28         * @since 4.8.0 Replaces the $blog_id property.
    3329         * @access public
    34          * @var string
     30         * @var int
    3531         */
    36         public $blog_id;
     32        public $id;
    3733
    3834        /**
    3935         * Domain of the site.
     
    5652        /**
    5753         * The ID of the site's parent network.
    5854         *
    59          * Named "site" vs. "network" for legacy reasons. An individual site's "site" is
    60          * its network.
    61          *
    62          * A numeric string, for compatibility reasons.
    63          *
    64          * @since 4.5.0
     55         * @since 4.8.0 Replaces the $site_id property.
    6556         * @access public
    66          * @var string
     57         * @var int
    6758         */
    68         public $site_id = '0';
     59        public $network_id = 0;
    6960
    7061        /**
    7162         * The date on which the site was created or registered.
     
    202193         */
    203194        public function __construct( $site ) {
    204195                foreach( get_object_vars( $site ) as $key => $value ) {
    205                         $this->$key = $value;
     196                        $this->__set( $key, $value );
    206197                }
    207198        }
    208199
     
    212203         * @since 4.6.0
    213204         * @access public
    214205         *
     206         * @deprecated 4.8.0 Use get_object_vars().
     207         *
    215208         * @return array Object as array.
    216209         */
    217210        public function to_array() {
    218                 return get_object_vars( $this );
     211                _deprecated_function( __METHOD__, '4.8.0', 'get_object_vars()' );
     212
     213                $data = get_object_vars( $this );
     214
     215                $data['blog_id'] = $data['id'];
     216                $data['site_id'] = $data['network_id'];
     217
     218                unset( $data['id'], $data['network_id'] );
     219
     220                return $data;
    219221        }
    220222
    221223        /**
     
    233235        public function __get( $key ) {
    234236                switch ( $key ) {
    235237                        case 'id':
    236                                 return (int) $this->blog_id;
     238                                return (int) $this->id;
    237239                        case 'network_id':
    238                                 return (int) $this->site_id;
     240                                return (int) $this->network_id;
    239241                        case 'blogname':
    240242                        case 'siteurl':
    241243                        case 'post_count':
     
    245247                                }
    246248                                $details = $this->get_details();
    247249                                return $details->$key;
     250
     251                        // Support blog_id for legacy reasons.
     252                        case 'blog_id':
     253                                return (string) $this->id;
     254
     255                        // Support site_id for legacy reasons.
     256                        case 'site_id':
     257                                return (string) $this->network_id;
    248258                }
    249259
    250260                return null;
     
    275285                                        return false;
    276286                                }
    277287                                return true;
     288
     289                        // Support blog_id and site_id for legacy reasons.
     290                        case 'blog_id':
     291                        case 'site_id':
     292                                return true;
    278293                }
    279294
    280295                return false;
     
    293308         */
    294309        public function __set( $key, $value ) {
    295310                switch ( $key ) {
     311                        // Support blog_id for legacy reasons.
     312                        case 'blog_id':
    296313                        case 'id':
    297                                 $this->blog_id = (string) $value;
     314                                $this->id = (int) $value;
    298315                                break;
     316
     317                        // Support site_id for legacy reasons.
     318                        case 'site_id':
    299319                        case 'network_id':
    300                                 $this->site_id = (string) $value;
     320                                $this->network_id = (int) $value;
    301321                                break;
    302322                        default:
    303323                                $this->$key = $value;