Opened 10 years ago
Closed 10 years ago
#31702 closed enhancement (fixed)
Add action to handle network not found for multisite
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 4.4 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Networks and Sites | Keywords: | has-patch |
Focuses: | multisite | Cc: |
Description
In a typical WordPress multisite installation, wp-config.php
will contain definitions for both DOMAIN_CURRENT_SITE
and PATH_CURRENT_SITE
. The current network global is then set up based on this, then the site is searched for using get_site_by_path
.
If the site isn't found, the ms_site_not_found
action is then fired, allowing plugins to handle this and display an appropriate error, or redirect to the signup page.
However! In a subdomain-based multi-network install, the site is searched for first based on the domain. If one is found, the network is set from that site's data; otherwise, the network is searched for independently.
If no network is found, ms_not_installed()
is called, with no way to set a "fallback" network and no actions or filters. The net result of this is that for multi-network installations, handling unknown domains (say, showing an information page as part of a domain mapping tool) is impossible. This means that domains have to show the DB error page, when the error is actually that they haven't been mapped to a site yet.
This was referenced in #30003, to which @jeremyfelt responded:
This is still expected behavior, but WordPress needs either
DOMAIN_CURRENT_SITE
andPATH_CURRENT_SITE
to be populated inwp-config.php
,$current_site
to be populated throughsunrise.php
, or the$current_site
global to be filled in via the lookup process so that it knows what network to redirect to.
...which is great and all, but the issue is that there's no way to handle this error in a custom way similar to the site-not-found error.
There's two ways I can see to handle this:
- Add an action after the site lookup process, to allow setting defaults on the globals or doing other actions.
- Add a
ms_network_not_found
action into theif ( empty( $current_site ) )
branch.
No. 2 is the easy choice, and I'd recommend adding it even if no. 1 is added. However, the first would help out during the normal request process as well.
Attachments (3)
Change History (9)
This ticket was mentioned in Slack in #core-multisite by rmccue. View the logs.
10 years ago
#3
@
10 years ago
- Milestone changed from Awaiting Review to Future Release
Let's look at this for 4.3.
Option 1: Add lookup hook