Make WordPress Core

Ticket #37050: 37050.3.diff

File 37050.3.diff, 1.9 KB (added by flixos90, 9 years ago)
  • src/wp-includes/class-wp-network.php

     
    1818 *
    1919 * @since 4.4.0
    2020 *
     21 * @property int $id
    2122 * @property int $site_id
    2223 */
    2324class WP_Network {
     
    2526        /**
    2627         * Network ID.
    2728         *
    28          * A numeric string, for compatibility reasons.
    29          *
    3029         * @since 4.4.0
    31          * @access public
    32          * @var string
     30         * @since 4.6.0 Type changed from string to int.
     31         * @access private
     32         * @var int
    3333         */
    34         public $id;
     34        private $id;
    3535
    3636        /**
    3737         * Domain of the network.
     
    6363         * @access private
    6464         * @var string
    6565         */
    66         private $blog_id = 0;
     66        private $blog_id = '0';
    6767
    6868        /**
    6969         * Domain used to set cookies for this network.
     
    152152         */
    153153        public function __get( $key ) {
    154154                switch ( $key ) {
     155                        case 'id';
     156                                return (int) $this->id;
    155157                        case 'blog_id':
    156158                                return $this->blog_id;
    157159                        case 'site_id':
     
    174176         */
    175177        public function __isset( $key ) {
    176178                switch ( $key ) {
     179                        case 'id':
    177180                        case 'blog_id':
    178181                        case 'site_id':
    179182                                return true;
     
    195198         */
    196199        public function __set( $key, $value ) {
    197200                switch ( $key ) {
     201                        case 'id':
     202                                $this->id = (int) $value;
     203                                break;
    198204                        case 'blog_id':
    199205                        case 'site_id':
    200206                                $this->blog_id = (string) $value;
  • tests/phpunit/tests/multisite/network.php

     
    8888        }
    8989
    9090        /**
     91         * @ticket 37050
     92         */
     93        function test_is_network_id_int() {
     94                $id = self::factory()->network->create();
     95
     96                $network = WP_Network::get_instance( $id );
     97
     98                $this->assertSame( (int) $id, $network->id );
     99        }
     100
     101        /**
    91102         * @ticket 22917
    92103         */
    93104        public function test_get_blog_count_no_filter_applied() {