Make WordPress Core

Ticket #38630: 38630.3.diff

File 38630.3.diff, 3.3 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'] = (string) $data['id'];
     216                $data['site_id'] = (string) $data['network_id'];
     217
     218                unset( $data['id'], $data['network_id'] );
     219
     220                return $data;
    219221        }
    220222
    221223        /**
     
    232234         */
    233235        public function __get( $key ) {
    234236                switch ( $key ) {
    235                         case 'id':
    236                                 return (int) $this->blog_id;
    237                         case 'network_id':
    238                                 return (int) $this->site_id;
    239237                        case 'blogname':
    240238                        case 'siteurl':
    241239                        case 'post_count':
     
    245243                                }
    246244                                $details = $this->get_details();
    247245                                return $details->$key;
     246
     247                        // Support blog_id for legacy reasons.
     248                        case 'blog_id':
     249                                return (string) $this->id;
     250
     251                        // Support site_id for legacy reasons.
     252                        case 'site_id':
     253                                return (string) $this->network_id;
    248254                }
    249255
    250256                return null;
     
    264270         */
    265271        public function __isset( $key ) {
    266272                switch ( $key ) {
    267                         case 'id':
    268                         case 'network_id':
    269                                 return true;
    270273                        case 'blogname':
    271274                        case 'siteurl':
    272275                        case 'post_count':
     
    275278                                        return false;
    276279                                }
    277280                                return true;
     281
     282                        // Support blog_id and site_id for legacy reasons.
     283                        case 'blog_id':
     284                        case 'site_id':
     285                                return true;
    278286                }
    279287
    280288                return false;
     
    293301         */
    294302        public function __set( $key, $value ) {
    295303                switch ( $key ) {
     304                        // Support blog_id for legacy reasons.
     305                        case 'blog_id':
    296306                        case 'id':
    297                                 $this->blog_id = (string) $value;
     307                                $this->id = (int) $value;
    298308                                break;
     309
     310                        // Support site_id for legacy reasons.
     311                        case 'site_id':
    299312                        case 'network_id':
    300                                 $this->site_id = (string) $value;
     313                                $this->network_id = (int) $value;
    301314                                break;
    302315                        default:
    303316                                $this->$key = $value;