Site search for a domain by text fails in subdomain installs of multisite with www in primary domain
|Reported by:||frisco||Owned by:|
1) Create a subdomain network install where the main site's domain contains www
2) On the Network Admin->Sites search for an existing site based on the domain name, such as some* to find somedomain.domain.com.
3) Search returns "No sites found." even when the site exists and was searched for using a valid technique.
I've tested the problem on Apache and Nginx servers, with Twenty Eleven as the theme on the main site, and network activated plugins. Existing sites can never be found by domain name.
Subdomain installs in a network are allowed where the main site is www.domain.com. DOMAIN_CURRENT_SITE in wp-config.php points to www.domain.com. But blogs.domain stores the domain of a multi-site site named somedomain as somedomain.domain.com (without the www).
As a result, any site search for a domain based on text (the name of the domain) fails because of how the query is built on lines 70-73 of wp-admin\inludes\class-wp-ms-sites-list-table.php. A search for some* produces a query that searches for some%.www.domain.com instead of some%.domain.com; the result is that nothing is ever found.
Searches based strictly on site ID work fine.
Possible fixes: 1) leave as is but warn that subdomain network installs where the primary domain includes www will have a broken site search (not ideal) and encourage no www on primary site of a subdomain network install or 2) check if the primary domain contains www and strip it out prior to building the query (ideal).