[wp-trac] [WordPress Trac] #36451: get_rest_url() not return SSL version of the URL when the home_url it's a subdomain

WordPress Trac noreply at wordpress.org
Fri Apr 8 15:28:17 UTC 2016


#36451: get_rest_url() not return SSL version of the URL when the home_url it's a
subdomain
--------------------------+-----------------------------
 Reporter:  nicholas_io   |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  REST API      |    Version:  4.4.2
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 The code below doesn't set the https scheme for some cases, I have a
 client site using a subdomain (it's a multisite installation) with SSL and
 the ajax requests to all REST route is failing due to the fact that
 get_rest_url is not returning the URL with https://. Debugging this showed
 to me that `$_SERVER["SERVER_NAME"]` is not returning the full site
 address (e.g if sub.domain.com it returns only domain.com) and thus the if
 clause fails and https is not set. I believe we can't really trust on
 SERVER_NAME.

 I'm not sure however if we really need this additional if check since
 we're already checking for is_ssl().

 rest-api.php L226
 {{{#!php
 if ( is_ssl() ) {
    if ( $_SERVER['SERVER_NAME'] === parse_url( get_home_url( $blog_id
 ),PHP_URL_HOST ) ) {
       $url = set_url_scheme( $url, 'https' );
    }
 }
 }}}

--
Ticket URL: <https://core.trac.wordpress.org/ticket/36451>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list