Make WordPress Core


Ignore:
Timestamp:
10/30/2015 02:01:32 AM (9 years ago)
Author:
johnbillion
Message:

Ensure that the scheme used in the URL returned by get_blogaddress_by_id() always reflects the blog's URL, instead of using http.

Props thomaswm
Fixes #14867

File:
1 edited

Legend:

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

    r35246 r35446  
    10001000        $blogaddress = get_blogaddress_by_id( 42 );
    10011001        $this->assertEquals( '', $blogaddress );
     1002    }
     1003
     1004    /**
     1005     * @ticket 14867
     1006     */
     1007    function test_get_blogaddress_by_id_scheme_reflects_blog_scheme() {
     1008        $blog = self::factory()->blog->create();
     1009
     1010        $this->assertSame( 'http', parse_url( get_blogaddress_by_id( $blog ), PHP_URL_SCHEME ) );
     1011
     1012        update_blog_option( $blog, 'home', set_url_scheme( get_blog_option( $blog, 'home' ), 'https' ) );
     1013
     1014        $this->assertSame( 'https', parse_url( get_blogaddress_by_id( $blog ), PHP_URL_SCHEME ) );
     1015    }
     1016
     1017    /**
     1018     * @ticket 14867
     1019     */
     1020    function test_get_blogaddress_by_id_scheme_is_unaffected_by_request() {
     1021        $blog = self::factory()->blog->create();
     1022
     1023        $this->assertFalse( is_ssl() );
     1024        $this->assertSame( 'http', parse_url( get_blogaddress_by_id( $blog ), PHP_URL_SCHEME ) );
     1025
     1026        $_SERVER['HTTPS'] = 'on';
     1027
     1028        $is_ssl  = is_ssl();
     1029        $address = parse_url( get_blogaddress_by_id( $blog ), PHP_URL_SCHEME );
     1030
     1031        unset( $_SERVER['HTTPS'] );
     1032
     1033        $this->assertTrue( $is_ssl );
     1034        $this->assertSame( 'http', $address );
    10021035    }
    10031036
Note: See TracChangeset for help on using the changeset viewer.