Make WordPress Core


Ignore:
Timestamp:
06/09/2016 06:09:25 PM (9 years ago)
Author:
jeremyfelt
Message:

Multisite: Use to_array() method on WP_Site objects in wp_get_sites()

When an object with private properties is cast directly to an array, those properties are no longer available with their original keys.

Props @flixos90.
See #36717.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/multisite/wpGetSites.php

    r37662 r37667  
    44
    55/**
     6 * @group wp-get-site
    67 * @group ms-site
    78 * @group multisite
     
    3031
    3132        wp_update_network_site_counts();
     33    }
     34
     35    /**
     36     * @expectedDeprecated wp_get_sites
     37     */
     38    public function test_wp_get_sites_site_is_expected_array() {
     39
     40        $keys = array(
     41            'blog_id',
     42            'site_id',
     43            'domain',
     44            'path',
     45            'registered',
     46            'last_updated',
     47            'public',
     48            'archived',
     49            'mature',
     50            'spam',
     51            'deleted',
     52            'lang_id'
     53        );
     54        $sites = wp_get_sites();
     55
     56        $missing_keys = array_diff_key( array_flip( $keys ), $sites[0] );
     57
     58        $this->assertEquals( array(), $missing_keys, 'Keys are missing from site arrays.' );
    3259    }
    3360
Note: See TracChangeset for help on using the changeset viewer.