WordPress.org

Make WordPress Core

Opened 8 weeks ago

#43851 new defect (bug)

Network admin allows updating one site to have the same domain and path as another site.

Reported by: giacocorsiglia Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 4.9.5
Component: Networks and Sites Keywords:
Focuses: administration, multisite Cc:

Description

The network admin page for updating sites in multisite (site-info.php) allows setting the domain and path on one site to match the domain and path on another site. This creates a conflict: if multiple sites have the same domain or path (depending on subdomain install vs. subdirectory install), only one of them can actually be accessed.

I would propose the following addition on line 82 of site-info.php:

<?php
// /wp-admin/network/site-info.php:82

if ( $blog_data['domain'] !== $existing_details->domain || $blog_data['path'] !== $existing_details->path ) {
    // A change to the domain or path was requested.
    if ( get_sites( [
        'domain' => $blog_data['domain'],
        'path' => $blog_data['path'],
        'site__not_in' => [ $id ], // Don't include the site we are changing.
        'number' => 1, // It's enough to know if one or more exist.
    ] ) ) {
        wp_die( __( 'Another site with that domain and path already exists.' ) );
    }
}

I don't think this is the case, but if it only needs to be unique by network, this can be added to the query:

'network_id' => $existing_details->site_id,

If there is some reason to not make this change, then I would appreciate the addition of a filter either on line 82 of site-info.php or in the update_blog_details() function that would allow the above check to be added by me or other developers. In fact, would be useful in either case!

Thank you!

Change History (0)

Note: See TracTickets for help on using tickets.