Opened 10 years ago
Closed 9 years ago
#31507 closed defect (bug) (invalid)
Error determined blog when using multi-site, a domain different than the current site, and more than 1 path segment
Reported by: | iotr | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 3.9 |
Component: | Networks and Sites | Keywords: | reporter-feedback |
Focuses: | multisite | Cc: |
Description
Steps to Reproduce
- Create a multi-site blog with SUBDOMAIN_INSTALL set to false and PATH_CURRENT_SITE set to /content/. Main site is now available at (http://www.example.com/content/)
- Create a new network with a different domain name than the domain for the current site (my.example.com)
- Set the path for the new network to have 2 path segments, for example /content/my-new-network
Expectation Navigating to http://my.example.com/content/my-new-network will show the new network
Result Redirection back to the primary site (http://www.example.com/content/) because no blog could be found at the path
More Details
We have a multi-site blog set up in a similar manner to the description above. The primary site is based at http://www.elocal.com/content/ and is configured in wp-config.php like:
define( 'DOMAIN_CURRENT_SITE', 'www.elocal.com' );
define( 'PATH_CURRENT_SITE', '/content/' );
define( 'SUBDOMAIN_INSTALL', false );
We then have a few networks. Some of these are under the domain www.elocal.com (e.g. http://www.elocal.com/content/home-expert-network/ ) while some are under other domains (e.g. http://www.elocallawyers.com/content/legal-resource-network/ ).
Upon upgrading from WordPress 3.7.1 to Wordpress 4.1.1, we found all of the blogs NOT on the same domain as the primary site (so not on www.elocal.com) no longer could be located, navigating to the links just resulted in a 302 back to the main blog page.
Upon researching the issue, I found the code responsible for looking up the appropriate blog from is restricting the lookup to only the first path segment source:trunk/src/wp-includes/ms-settings.php?rev=28934#L65 (the third argument to get_site_by_path is 1. So because the path for the blog on domain www.elocallawyers.com with two path segments (content and legal-resource-network), but we are limiting the path to only one path segment (/, or /content/), we cannot find the blog.
I was able to perform a temporary workaround by changing the third argument to a 2, which at least got me back up and running.
I'm not sure what a great solution would be. A couple of options that I can think of:
- Do not restrict the number of page segments for non current_site blog lookups
- Allow for this to be a configuration setting so I could set the maximum number of lookups.
- Use the same number of content segments as you would for a blog on the main site. That is 1 more than the number of segments for the main blog.
Attachments (1)
Change History (4)
#2
@
10 years ago
For reference, I attached the patch with changes that I made.
Thank you for the site_by_path_segments_count
suggestion, I'll try to use that instead.
We are not using a plugin or any custom code to manage the creation. To do so, I just create a new network and then edit it to set the domain.
Hi @iotr, thanks for the report!
The filter
site_by_path_segments_count
is available inget_site_by_path()
for this specific instance. You can use that to override the path count to 2 in your case.The move to using this method happened in #27003. It may be worth going through that to see the decision making.
Are you using a plugin or custom code to manage the creation of networks and sites with different domains? I'd like to make sure we've done everything possible to help in the transition process.