Make WordPress Core

Opened 9 months ago

Last modified 3 months ago

#24833 new enhancement

Multisite site search for subdomain install with mapped domains

Reported by: Surbma Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 3.5.2
Component: Networks and Sites Keywords:
Focuses: multisite Cc:


Site search is not working in a Multisite with subdomain install, when a sub site's domain is changed and not using the main site's domain in its own domain. It means it is not a subdomain of the main site.

Mainly it affects sub sites with domain mapping.

In the file: /wp-admin/includes/class-wp-ms-sites-list-table.php there is the search query, which has the main site's domain hardcoded in the query ($current_site->domain). So it needs to be changed to search for all kind of domains.

I don't know much about this code, but I have found a fix and it is working, so I add it here.

This code needs to be put in the /wp-admin/includes/class-wp-ms-sites-list-table.php file after the 73rd line in WP 3.5.2:

$blog_s = '$wild' . $like_s . '$wild'; // fix

Change History (8)

comment:1 markoheijnen9 months ago

If the issue is only with mapped domains then it's not really an issue in WordPress because you need a plugin for that but you do have a point about having it hardcoded. Maybe a filter on the query would make sense.

I don't think your fix is a real fix but I can be wrong about the issue you are having. When you want the ability to search on mapped domains then you need to look into another table. So a like query will not fix that.

comment:2 Surbma9 months ago

WordPress Multisite has the feature to change the domain of a subsite without any plugin, so it is indeed an issue with WordPress core.

The best way to use custom domains is with domain mapping, but it is not mandatory. So the WordPress core needs to be fixed to search for other domains, than the main site's subdomains.

It is not my code, I don't know much about database query, I just know, that I put this code to the file and now the domain search function is working fine.

So this fix needs a developer, who understands how it works and change the code accordingly.

comment:3 DrewAPicture9 months ago

  • Cc xoodrew@… added

comment:4 follow-up: markoheijnen9 months ago

I looked into it and I'm mixed. I think simplifying $blog_s would be cool but that would also mean searching on the network domain name will always show everything.

I think in this situation a filter maybe makes more sense then changing $blog_s. So you change only that small part of the query.

comment:5 in reply to: ↑ 4 Surbma9 months ago

Replying to markoheijnen:

searching on the network domain name will always show everything

Not for me. ;) I use almost only custom domains in my network. So it makes sense for me to search for the network domain as it will show me all the blogs without any custom domains.

For others without any custom domains, what is the problem if it shows all subdomains, if somebody search for the network domain? Main site is always the first in the list, there is no need to search for it.

comment:6 markoheijnen9 months ago

So a filter will work for you ;) I just mentioning the possible negative impact of it. The key is that the search only shows real results and not because the main domain is in the domain name

comment:7 Surbma9 months ago

Ok, I believe you. Every solution is good for me, what works for everybody, in every case. :)

I just told you a situation, where searching for the network domain makes sense if it really shows all blogs with that domain.

So just to understand your solution, what if I search for the network domain in your case? What will it show? If it doesn't show all blogs, just the main site, how can I search for all blogs without custom domains?

comment:8 jeremyfelt3 months ago

  • Component changed from Multisite to Networks and Sites
  • Focuses multisite added
Note: See TracTickets for help on using tickets.