Opened 7 years ago
Last modified 7 years ago
#42557 new defect (bug)
Wrong Behaviour on get_site_url for multiple sites with different protocol
Reported by: | matteowebsolution | Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | normal | Version: | 4.9 |
Component: | Networks and Sites | Keywords: | |
Focuses: | multisite | Cc: |
Description
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?
Note: See
TracTickets for help on using
tickets.
Hello!
I came here to post the same issue, and then dig around little more..
Here is a quickfix.
wp-includes/link-template.php (line 3020; get_site_url()):
if ( parse_url( $url, PHP_URL_SCHEME ) == 'http' ) $scheme = 'http';
However I'm new to WordPress and this might not be an acceptable solution!