WordPress.org

Make WordPress Core


Ignore:
Timestamp:
03/02/2014 10:24:50 PM (6 years ago)
Author:
nacin
Message:

Introduce get_site_by_path() and further rewrite the site detection process for multisite.

This is the first big step to supporting arbitrary domains and paths. In this new approach, sites are detected first where possible, then the network is inferred. Allows filtering for arbitrary path segments, smooths out some weirdness, and removes various restrictions. A sunrise plugin could do much of its work by adding filters, if those are even needed.

see #27003.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/ms.php

    r27290 r27359  
    12221222
    12231223    /**
     1224     * @ticket 27003
     1225     */
     1226    function test_get_site_by_path() {
     1227        $ids = array(
     1228            'wordpress.org/'              => array( 'domain' => 'wordpress.org',      'path' => '/' ),
     1229            'wordpress.org/foo/'          => array( 'domain' => 'wordpress.org',      'path' => '/foo/' ),
     1230            'wordpress.org/foo/bar/'      => array( 'domain' => 'wordpress.org',      'path' => '/foo/bar/' ),
     1231            'make.wordpress.org/'         => array( 'domain' => 'make.wordpress.org', 'path' => '/' ),
     1232            'make.wordpress.org/foo/'     => array( 'domain' => 'make.wordpress.org', 'path' => '/foo/' ),
     1233        );
     1234
     1235        foreach ( $ids as &$id ) {
     1236            $id = $this->factory->blog->create( $id );
     1237        }
     1238        unset( $id );
     1239
     1240        $this->assertEquals( $ids['wordpress.org/'],
     1241            get_site_by_path( 'wordpress.org', '/notapath/' )->blog_id );
     1242
     1243        $this->assertEquals( $ids['wordpress.org/foo/bar/'],
     1244            get_site_by_path( 'wordpress.org', '/foo/bar/baz/' )->blog_id );
     1245
     1246        $this->assertEquals( $ids['wordpress.org/foo/bar/'],
     1247            get_site_by_path( 'wordpress.org', '/foo/bar/baz/', 3 )->blog_id );
     1248
     1249        $this->assertEquals( $ids['wordpress.org/foo/bar/'],
     1250            get_site_by_path( 'wordpress.org', '/foo/bar/baz/', 2 )->blog_id );
     1251
     1252        $this->assertEquals( $ids['wordpress.org/foo/'],
     1253            get_site_by_path( 'wordpress.org', '/foo/bar/baz/', 1 )->blog_id );
     1254
     1255        $this->assertEquals( $ids['wordpress.org/'],
     1256            get_site_by_path( 'wordpress.org', '/', 0 )->blog_id );
     1257
     1258        $this->assertEquals( $ids['make.wordpress.org/foo/'],
     1259            get_site_by_path( 'make.wordpress.org', '/foo/bar/baz/qux/', 4 )->blog_id );
     1260    }
     1261
     1262    /**
    12241263     * @ticket 20601
    12251264     */
Note: See TracChangeset for help on using the changeset viewer.