Make WordPress Core

Ticket #40503: 40503.3.diff

File 40503.3.diff, 3.4 KB (added by flixos90, 8 years ago)
  • src/wp-includes/ms-functions.php

     
    11531153 *                        updated. Otherwise, keys and values will be used to set options for
    11541154 *                        the new site. Default empty array.
    11551155 * @param int    $site_id Optional. Only relevant on multi-network installs.
    1156  * @return int|WP_Error Returns WP_Error object on failure, int $blog_id on success
     1156 * @return int|WP_Error Returns WP_Error object on failure, the new site ID on success.
    11571157 */
    11581158function wpmu_create_blog( $domain, $path, $title, $user_id, $meta = array(), $site_id = 1 ) {
    11591159        $defaults = array(
    11601160                'public' => 0,
    1161                 'WPLANG' => get_site_option( 'WPLANG' ),
     1161                'WPLANG' => get_network_option( $site_id, 'WPLANG' ),
    11621162        );
    11631163        $meta = wp_parse_args( $meta, $defaults );
    11641164
     
    12081208         *
    12091209         * @since MU
    12101210         *
    1211          * @param int    $blog_id Blog ID.
     1211         * @param int    $blog_id Site ID.
    12121212         * @param int    $user_id User ID.
    12131213         * @param string $domain  Site domain.
    12141214         * @param string $path    Site path.
    1215          * @param int    $site_id Site ID. Only relevant on multi-network installs.
     1215         * @param int    $site_id Network ID. Only relevant on multi-network installs.
    12161216         * @param array  $meta    Meta data. Used to set initial site options.
    12171217         */
    12181218        do_action( 'wpmu_new_blog', $blog_id, $user_id, $domain, $path, $site_id, $meta );
  • tests/phpunit/tests/multisite/site.php

     
    1010 */
    1111class Tests_Multisite_Site extends WP_UnitTestCase {
    1212        protected $suppress = false;
     13        protected static $network_ids;
    1314
    1415        function setUp() {
    1516                global $wpdb;
     
    2324                parent::tearDown();
    2425        }
    2526
     27        public static function wpSetUpBeforeClass( $factory ) {
     28                self::$network_ids = array(
     29                        'make.wordpress.org/' => array( 'domain' => 'make.wordpress.org', 'path' => '/' ),
     30                );
     31
     32                foreach ( self::$network_ids as &$id ) {
     33                        $id = $factory->network->create( $id );
     34                }
     35                unset( $id );
     36        }
     37
     38        public static function wpTearDownAfterClass() {
     39                global $wpdb;
     40
     41                foreach( self::$network_ids as $id ) {
     42                        $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->sitemeta} WHERE site_id = %d", $id ) );
     43                        $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->site} WHERE id= %d", $id ) );
     44                }
     45        }
     46
    2647        function test_switch_restore_blog() {
    2748                global $_wp_switched_stack, $wpdb;
    2849
     
    9811002        }
    9821003
    9831004        /**
     1005         * @ticket 40503
     1006         */
     1007        function test_different_network_language() {
     1008                $network = get_network( self::$network_ids['make.wordpress.org/'] );
     1009
     1010                add_filter( 'sanitize_option_WPLANG', array( $this, 'filter_allow_unavailable_languages' ), 10, 3 );
     1011
     1012                update_network_option( self::$network_ids['make.wordpress.org/'], 'WPLANG', 'wibble' );
     1013                $blog_id = wpmu_create_blog( $network->domain, '/de-de/', 'New Blog', get_current_user_id(), array(), $network->id );
     1014
     1015                remove_filter( 'sanitize_option_WPLANG', array( $this, 'filter_allow_unavailable_languages' ), 10 );
     1016
     1017                $this->assertSame( get_network_option( self::$network_ids['make.wordpress.org/'], 'WPLANG' ), get_blog_option( $blog_id, 'WPLANG' ) );
     1018        }
     1019
     1020        /**
    9841021         * Allows to set the WPLANG option to any language.
    9851022         *
    9861023         * @param string $value          The sanitized option value.