Make WordPress Core

Ticket #20589: 20589.2.diff

File 20589.2.diff, 1.4 KB (added by ericmann, 11 years ago)

Adds a test to verify trailingslashit behavior.

  • src/wp-includes/ms-functions.php

     
    12891289 */
    12901290function domain_exists($domain, $path, $site_id = 1) {
    12911291        global $wpdb;
     1292
     1293        $path = trailingslashit( $path );
     1294
    12921295        $result = $wpdb->get_var( $wpdb->prepare("SELECT blog_id FROM $wpdb->blogs WHERE domain = %s AND path = %s AND site_id = %d", $domain, $path, $site_id) );
    12931296        /**
    12941297         * Filter whether a blogname is taken.
  • tests/phpunit/tests/ms.php

     
    962962        }
    963963
    964964        function _domain_exists_cb( $exists, $domain, $path, $site_id ) {
    965                 if ( 'foo' == $domain && 'bar' == $path )
     965                if ( 'foo' == $domain && 'bar/' == $path )
    966966                        return 1234;
    967967                else
    968968                        return null;
     
    984984                $this->assertEquals( null, domain_exists( 'foo', 'baz' ) );
    985985                $this->assertEquals( null, domain_exists( 'bar', 'foo' ) );
    986986
     987                // Make sure the same result is returned with or without a trailing slash
     988                $this->assertEquals( domain_exists( 'foo', 'bar' ), domain_exists( 'foo', 'bar/' ) );
     989
    987990                remove_filter( 'domain_exists', array( $this, '_domain_exists_cb' ), 10, 4 );
    988991                $this->assertEquals( null, domain_exists( 'foo', 'bar' ) );
    989992