WordPress.org

Make WordPress Core

Opened 3 years ago

Last modified 20 months ago

#14867 reopened defect (bug)

HTTPS related issues in ms-blogs.php (with fix)

Reported by: mareck Owned by:
Priority: normal Milestone: Future Release
Component: Multisite Version:
Severity: normal Keywords: has-patch
Cc: adambackstrom

Description

Two functions in ms-blogs.php have issues due to hard-coding "http://" versus using the is_ssl() check. I have corrected them below. Just copy and paste these over the ones in your ms-blogs.php.

function get_blogaddress_by_id( $blog_id ) {

$protocol = is_ssl() ? 'https://' : 'http://';

$bloginfo = get_blog_details( (int) $blog_id, false ); only get bare details!
return esc_url( $protocol . $bloginfo->domain . $bloginfo->path );

}

function get_blogaddress_by_domain( $domain, $path ){

$protocol = is_ssl() ? 'https://' : 'http://';

if ( is_subdomain_install() ) {

$url = $protocol.$domain.$path;

} else {

if ( $domain != $_SERVERHTTP_HOST? ) {

$blogname = substr( $domain, 0, strpos( $domain, '.' ) );

$url = $protocol . substr( $domain, strpos( $domain, '.' ) + 1 ) . $path;

we're not installing the main blog
if ( $blogname != 'www.' )

$url .= $blogname . '/';

} else { main blog

$url = $protocol . $domain . $path;

}

}
return esc_url( $url );

}

Attachments (2)

14867.diff (1.4 KB) - added by scribu 3 years ago.
14867-protocol-args.diff (3.3 KB) - added by adambackstrom 3 years ago.

Download all attachments as: .zip

Change History (16)

scribu3 years ago

comment:2 scribu3 years ago

  • Keywords has-patch added
  • Milestone changed from Awaiting Review to 3.1

comment:3 scribu3 years ago

Oh well...

comment:4 follow-up: ryan3 years ago

I think we would have to add a protocol argument to these functions.

comment:5 in reply to: ↑ 4 nacin3 years ago

  • Keywords needs-patch added; has-patch removed

Replying to ryan:

I think we would have to add a protocol argument to these functions.

Yeah.

comment:6 adambackstrom3 years ago

Added patch for $ssl argument to both functions. Modified wp-admin/network/site-info.php to have a UI for this flag.

install_blog(), wpmu_welcome_notification(), and wpmu_activate_stylesheet() were left alone, and will autodetect SSL.

comment:7 adambackstrom3 years ago

  • Cc adambackstrom added
  • Keywords has-patch added; needs-patch removed

comment:8 nacin3 years ago

This looks good. Notes:

  1. No need for the UI option. The changes in site-info.php can be entirely dropped I think.
  1. Argument should be $scheme and should take 'https' and 'http' as valid values, default null at which point we use is_ssl. This allows us to add other protocols and it is also in line with functions in wp-includes/link-template.php.
  1. General whitespace. Looks good mostly, but !isset($ssl) should be ! isset( $ssl ).

Going to run with this. Thanks for the initial patch.

comment:9 nacin3 years ago

  • Resolution set to fixed
  • Status changed from new to closed

(In [16987]) Add scheme arguments to get_blogaddress_by_domain and get_blogaddress_by_id. props adambackstrom for initial patch, fixes #14867.

comment:10 ryan3 years ago

(In [17005]) Revert [16987]. This pollutes home and siteurl during signup and blog creation. see #14867

comment:11 ryan3 years ago

  • Milestone changed from 3.1 to Future Release
  • Resolution fixed deleted
  • Status changed from closed to reopened

comment:12 exell.christopher2 years ago

Any news on this? This is turning out to be quite the maintenance headache for my particular install as we are running everything under ssl and have to go change the siteurl and home settings every time we setup a new blog.

comment:13 scribu2 years ago

You can automate that by hooking into the 'wpmu_new_blog' action.

comment:14 SergeyBiryukov20 months ago

Closed #18931 as a duplicate.

Note: See TracTickets for help on using tickets.