[wp-trac] [WordPress Trac] #42557: Wrong Behaviour on get_site_url for multiple sites with different protocol

WordPress Trac noreply at wordpress.org
Wed Nov 15 14:41:29 UTC 2017


#42557: Wrong Behaviour on get_site_url for multiple sites with different protocol
--------------------------------+-----------------------------
 Reporter:  matteowebsolution   |      Owner:
     Type:  defect (bug)        |     Status:  new
 Priority:  normal              |  Milestone:  Awaiting Review
Component:  Networks and Sites  |    Version:  4.9
 Severity:  normal              |   Keywords:
  Focuses:  multisite           |
--------------------------------+-----------------------------
 Hi guys,
 i think i found something that imho isn't working at all as expected.

 Let's go with some explaination:

 * I have a multisite network which has 4 sites
 * 1 site, the main one, is under HTTPS protocol, the rest are under normal
 HTTP
 * I've made a unique theme, customized for all 4 sites
 * '''I don't want to pass the scheme to get_site_url()''' , this should be
 created dinamically

 In theme footer, i'm calling the function {{{ get_site_url() }}} for
 pointing each site to other ones.

 Something really bad happens here:

 * The first site (the https:// one) show all the links with https on top,
 and it's totally wrong as the remaining sites are all under http
 * Instead, the remaining sites show all the link with http on top,
 included the first https one

 So, after inspecting a while, it seems you're doing something i cannot
 really explain...

 * function get_site_url (link-template.php, row 3063) get the siteurl
 option from database using get_option('siteurl') and then you call
 set_url_scheme
 * function set_url_scheme will be blocked from first condition check {{{
 if(! $scheme) }}}, so we're going to is_ssl()
 * and here we are with something misunderstood... function is_ssl() checks
 if $_SERVER[ 'HTTPS' ] global var is set and return true or false for the
 current server configuration, not bothering of other sites configuration
 (!?!?!?!?!?)
 * so when i interrogate a HTTPS site, all links will be ssl, when i
 interrogate a HTTP site, all links won't have ahead that protocol.

 I don't think this is an optimal way to check this thing honestly...

 Could we discuss about it?

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


More information about the wp-trac mailing list