#21837 closed defect (bug) (fixed)
Site search for a domain by text fails in subdomain installs of multisite with www in primary domain
Reported by: | frisco | Owned by: | jeremyfelt |
---|---|---|---|
Milestone: | 4.6 | Priority: | normal |
Severity: | normal | Version: | 3.0 |
Component: | Networks and Sites | Keywords: | has-patch |
Focuses: | multisite | Cc: |
Description
To reproduce:
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).
Attachments (4)
Change History (21)
#3
@
11 years ago
- Keywords needs-patch added
- Milestone changed from Awaiting Review to Future Release
- Version changed from 3.4.2 to 3.0
Thanks for the ticket, @frisco. Sorry to leave you hanging so long.
A message was added via #11945 as a warning. The following displays when configuring multisite on a www domain:
We recommend you change your siteurl to wordpress.dev before enabling the network feature. It will still be possible to visit your site using the www prefix with an address like www.wordpress.dev but any links will not have the www prefix.
That said. :)
Site search is pretty wobbly right now. I'm not finding another ticket at the moment that covers site search in general, and it's something that could use a bit of work. I don't think it would be too tough to expand the current logic to do a better job. It would probably be best to ignore parsing the request against $current_site->domain
and focus instead on whatever is being searched for.
#4
@
11 years ago
@jeremyfelt - Thanks for the follow up. Couple of things:
1) If I understand correctly, the message added doesn't seem accurate with the phrase "any links will not...." When I posted my original issue, without the www, links on the main site did have the www; if that was changed, it would seem odd. It seems the intended explanation is that subdomains and any links on them (not links on the main site) will not have the www prefix. Domain mapping throws another wrinkle into that message, because www can appear in a mapped subdomain and its links. I think the message can be improved to say specifically that with www on the main site, site search on multisite won't work.
2) It's been a while since I looked at the relevant code, but I recall thinking that it would be straightforward to fix the search logic so it took into account www or no www. I'm happy to take a stab at that, but if multisite is getting bigger overhauls that might change this code, maybe that's not a productive approach. If the overhauls are otherwise going to leave this alone, then it ought to be fixed.
This isn't a burning issue for me personally, because once I realized the problem, I switched my networks to drop www on the main site, but I'm happy to try to provide a fix to help others.
#5
@
11 years ago
1 - I'm going to have to poke around at the www linking a bit. It's entirely possible that things are backwards a bit there.
2 - Absolutely! I would be happy to test any improvements made there. From looking at the code last night, I think it's only a few changes from being drastically improved.
#6
@
11 years ago
@jeremyfelt - Ok, I'll try to put something together and post back. Might take me at least a week + with everything else going on, but I'll get to it.
This ticket was mentioned in Slack in #core by jeremyfelt. View the logs.
9 years ago
#9
@
9 years ago
In get_blog_details()
if you’re searching by domain/path — https://core.trac.wordpress.org/browser/tags/4.2.2/src/wp-includes/ms-blogs.php#L115 — if searching for a domain with a www.
prefix, it looks like it will find the result either with or without. But if searching for the domain without the www.
prefix, it won’t catch an entry that has www.
prefixed on the domain.
It doesn’t look like the www.
gets stripped in update_blog_details()
anywhere either.
Not sure if this is precisely the same issue, but I'll try to write a patch shortly, but in case I forget, documenting stuff here for future generations.
#10
@
9 years ago
Just ran into this, but with a different configuration other than www.
.
- Primary site of network:
demo.example.com
- Secondary sites of network:
foo.example.com
,bar.example.com
, etc...
When attempting to search for sites, it looks for search%.demo.example.com
.
I believe @jeremyfelt's first assessment to avoid concatenating $current_site->domain
is the bare minimum. I'll go 1 step further and say that my expectation as a network admin is to see results from both the domain
and path
regardless of installation type, and let me narrow the results with more precise search strings if necessary.
This ticket was mentioned in Slack in #core-multisite by ocean90. View the logs.
9 years ago
This ticket was mentioned in Slack in #core-multisite by jeremyfelt. View the logs.
8 years ago
#14
@
8 years ago
- Keywords has-patch added; needs-patch removed
- Owner set to jeremyfelt
- Status changed from new to assigned
Related: #23088