Make WordPress Core

Changeset 37870


Ignore:
Timestamp:
06/26/2016 01:22:36 PM (10 years ago)
Author:
jeremyfelt
Message:

Multisite: Change WP_Network id property to an integer.

For consistency and developer sanity.

Props flixos90.
Fixes #37050.

Location:
trunk
Files:
2 edited

Legend:

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

    r37658 r37870  
    1919 * @since 4.4.0
    2020 *
     21 * @property int $id
    2122 * @property int $site_id
    2223 */
    … …  
    2627         * Network ID.
    2728         *
    28          * A numeric string, for compatibility reasons.
    29          *
    30          * @since 4.4.0
    31          * @access public
    32          * @var string
    33          */
    34         public $id;
     29         * @since 4.4.0
     30         * @since 4.6.0 Type changed from string to int.
     31         * @access private
     32         * @var int
     33         */
     34        private $id;
    3535
    3636        /**
    … …  
    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;
    … …  
    175177        public function __isset( $key ) {
    176178                switch ( $key ) {
     179                        case 'id':
    177180                        case 'blog_id':
    178181                        case 'site_id':
    … …  
    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':
  • trunk/tests/phpunit/tests/multisite/network.php

    r37300 r37870  
    8989
    9090        /**
     91         * @ticket 37050
     92         */
     93        function test_wp_network_object_id_property_is_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         */
Note: See TracChangeset for help on using the changeset viewer.