WordPress.org

Make WordPress Core

Ticket #27884: 27884.2.diff

File 27884.2.diff, 7.8 KB (added by jeremyfelt, 7 years ago)
  • src/wp-includes/ms-settings.php

     
    1010 * @since 3.0.0
    1111 */
    1212
    13 /** Include Multisite initialization functions */
    14 require( ABSPATH . WPINC . '/ms-load.php' );
    15 require( ABSPATH . WPINC . '/ms-default-constants.php' );
    16 
    17 if ( defined( 'SUNRISE' ) )
     13if ( defined( 'SUNRISE' ) ) {
    1814        include_once( WP_CONTENT_DIR . '/sunrise.php' );
     15}
    1916
    2017/** Check for and define SUBDOMAIN_INSTALL and the deprecated VHOST constant. */
    2118ms_subdomain_constants();
  • src/wp-settings.php

     
    9191// Initialize multisite if enabled.
    9292if ( is_multisite() ) {
    9393        require( ABSPATH . WPINC . '/ms-blogs.php' );
     94        /** Include Multisite initialization functions */
     95        require( ABSPATH . WPINC . '/ms-load.php' );
     96        require( ABSPATH . WPINC . '/ms-default-constants.php' );
    9497        require( ABSPATH . WPINC . '/ms-settings.php' );
    9598} elseif ( ! defined( 'MULTISITE' ) ) {
    9699        define( 'MULTISITE', false );
  • tests/phpunit/includes/bootstrap.php

     
    5555        echo "Running as multisite..." . PHP_EOL;
    5656        define( 'MULTISITE', true );
    5757        define( 'SUBDOMAIN_INSTALL', false );
    58         define( 'DOMAIN_CURRENT_SITE', WP_TESTS_DOMAIN );
    59         define( 'PATH_CURRENT_SITE', '/' );
    60         define( 'SITE_ID_CURRENT_SITE', 1 );
    61         define( 'BLOG_ID_CURRENT_SITE', 1 );
    6258        $GLOBALS['base'] = '/';
    6359} else {
    6460        echo "Running as single site... To run multisite, use -c tests/phpunit/multisite.xml" . PHP_EOL;
  • tests/phpunit/tests/ms.php

     
    455455                $blog_id = $this->factory->blog->create( array( 'user_id' => $user_id, 'path' => '/test_blogname', 'title' => 'Test Title' ) );
    456456                $this->assertInternalType( 'int', $blog_id );
    457457
    458                 $this->assertEquals( 'http://' . DOMAIN_CURRENT_SITE . PATH_CURRENT_SITE . 'test_blogname/', get_blogaddress_by_name('test_blogname') );
     458                $this->assertEquals( 'http://' . $current_site->domain . $current_site->path . 'test_blogname/', get_blogaddress_by_name('test_blogname') );
    459459
    460460                $this->assertEquals( $blog_id, get_id_from_blogname('test_blogname') );
    461461        }
     
    14101410                $details = get_blog_details( get_current_blog_id() );
    14111411                $this->assertEquals( 'bar', $details->blogname );
    14121412        }
     1413
     1414        /**
     1415         * @ticket 27884
     1416         *
     1417         * @expectedDeprecated define()
     1418         */
     1419        function test_multisite_bootstrap() {
     1420                global $current_site, $current_blog;
     1421
     1422                $network_ids = array(
     1423                        'wordpress.org/'         => array( 'domain' => 'wordpress.org', 'path' => '/' ),
     1424                        'make.wordpress.org/'    => array( 'domain' => 'make.wordpress.org', 'path' => '/' ),
     1425                );
     1426
     1427                foreach ( $network_ids as &$id ) {
     1428                        $id = $this->factory->network->create( $id );
     1429                }
     1430                unset( $id );
     1431
     1432                $ids = array(
     1433                        'wordpress.org/'              => array( 'domain' => 'wordpress.org',      'path' => '/',         'site_id' => $network_ids['wordpress.org/'] ),
     1434                        'wordpress.org/foo/'          => array( 'domain' => 'wordpress.org',      'path' => '/foo/',     'site_id' => $network_ids['wordpress.org/'] ),
     1435                        'wordpress.org/foo/bar/'      => array( 'domain' => 'wordpress.org',      'path' => '/foo/bar/', 'site_id' => $network_ids['wordpress.org/'] ),
     1436                        'make.wordpress.org/'         => array( 'domain' => 'make.wordpress.org', 'path' => '/',         'site_id' => $network_ids['make.wordpress.org/'] ),
     1437                        'make.wordpress.org/foo/'     => array( 'domain' => 'make.wordpress.org', 'path' => '/foo/',     'site_id' => $network_ids['make.wordpress.org/'] ),
     1438                );
     1439
     1440                foreach ( $ids as &$id ) {
     1441                        $id = $this->factory->blog->create( $id );
     1442                }
     1443                unset( $id );
     1444
     1445                $this->_setup_host_request( 'wordpress.org', '/' );
     1446                $this->assertEquals( $ids['wordpress.org/'], $current_blog->blog_id );
     1447                $this->assertEquals( $network_ids['wordpress.org/'], $current_blog->site_id );
     1448
     1449                $this->_setup_host_request( 'wordpress.org', '/2014/04/23/hello-world/' );
     1450                $this->assertEquals( $ids['wordpress.org/'], $current_blog->blog_id );
     1451                $this->assertEquals( $network_ids['wordpress.org/'], $current_blog->site_id );
     1452
     1453                $this->_setup_host_request( 'wordpress.org', '/sample-page/' );
     1454                $this->assertEquals( $ids['wordpress.org/'], $current_blog->blog_id );
     1455                $this->assertEquals( $network_ids['wordpress.org/'], $current_blog->site_id );
     1456
     1457                $this->_setup_host_request( 'wordpress.org', '/?p=1' );
     1458                $this->assertEquals( $ids['wordpress.org/'], $current_blog->blog_id );
     1459                $this->assertEquals( $network_ids['wordpress.org/'], $current_blog->site_id );
     1460
     1461                $this->_setup_host_request( 'wordpress.org', '/wp-admin/' );
     1462                $this->assertEquals( $ids['wordpress.org/'], $current_blog->blog_id );
     1463                $this->assertEquals( $network_ids['wordpress.org/'], $current_blog->site_id );
     1464
     1465                $this->_setup_host_request( 'wordpress.org', '/foo/' );
     1466                $this->assertEquals( $ids['wordpress.org/foo/'], $current_blog->blog_id );
     1467                $this->assertEquals( $network_ids['wordpress.org/'], $current_blog->site_id );
     1468
     1469                $this->_setup_host_request( 'wordpress.org', '/FOO/' );
     1470                $this->assertEquals( $ids['wordpress.org/foo/'], $current_blog->blog_id );
     1471                $this->assertEquals( $network_ids['wordpress.org/'], $current_blog->site_id );
     1472
     1473                $this->_setup_host_request( 'wordpress.org', '/foo/2014/04/23/hello-world/' );
     1474                $this->assertEquals( $ids['wordpress.org/foo/'], $current_blog->blog_id );
     1475                $this->assertEquals( $network_ids['wordpress.org/'], $current_blog->site_id );
     1476
     1477                $this->_setup_host_request( 'wordpress.org', '/foo/sample-page/' );
     1478                $this->assertEquals( $ids['wordpress.org/foo/'], $current_blog->blog_id );
     1479                $this->assertEquals( $network_ids['wordpress.org/'], $current_blog->site_id );
     1480
     1481                $this->_setup_host_request( 'wordpress.org', '/foo/?p=1' );
     1482                $this->assertEquals( $ids['wordpress.org/foo/'], $current_blog->blog_id );
     1483                $this->assertEquals( $network_ids['wordpress.org/'], $current_blog->site_id );
     1484
     1485                $this->_setup_host_request( 'wordpress.org', '/foo/wp-admin/' );
     1486                $this->assertEquals( $ids['wordpress.org/foo/'], $current_blog->blog_id );
     1487                $this->assertEquals( $network_ids['wordpress.org/'], $current_blog->site_id );
     1488
     1489                // @todo not currently passing.
     1490                //$this->_setup_host_request( 'wordpress.org', '/foo/bar/' );
     1491                //$this->assertEquals( $ids['wordpress.org/foo/bar/'], $current_blog->blog_id );
     1492                //$this->assertEquals( $network_ids['wordpress.org/'], $current_blog->site_id );
     1493
     1494                $this->_setup_host_request( 'make.wordpress.org', '/' );
     1495                $this->assertEquals( $ids['make.wordpress.org/'], $current_blog->blog_id );
     1496                $this->assertEquals( $network_ids['make.wordpress.org/'], $current_blog->site_id );
     1497
     1498                $this->_setup_host_request( 'make.wordpress.org', '/foo/' );
     1499                $this->assertEquals( $ids['make.wordpress.org/foo/'], $current_blog->blog_id );
     1500                $this->assertEquals( $network_ids['make.wordpress.org/'], $current_blog->site_id );
     1501        }
     1502
     1503        /**
     1504         * Reset various globals required for a 'clean' multisite boot.
     1505         *
     1506         * The $wpdb and $table_prefix globals are required for ms-settings.php to
     1507         * load properly.
     1508         *
     1509         * @param string $domain HTTP_HOST of the bootstrap request.
     1510         * @param string $path   REQUEST_URI of the boot strap request.
     1511         */
     1512        function _setup_host_request( $domain, $path ) {
     1513                global $current_site, $current_blog, $wpdb, $table_prefix;
     1514
     1515                $current_site = $current_blog = null;
     1516                $_SERVER['HTTP_HOST'] = $domain;
     1517                $_SERVER['REQUEST_URI'] = $path;
     1518
     1519                include ABSPATH . '/wp-includes/ms-settings.php';
     1520        }
    14131521}
    14141522
    14151523endif;