[wp-trac] [WordPress Trac] #31702: Add action to handle network not found for multisite
WordPress Trac
noreply at wordpress.org
Fri Mar 20 02:41:56 UTC 2015
#31702: Add action to handle network not found for multisite
--------------------------------+-----------------------------
Reporter: rmccue | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Networks and Sites | Version:
Severity: normal | Keywords:
Focuses: multisite |
--------------------------------+-----------------------------
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` and `PATH_CURRENT_SITE` to be populated in `wp-
config.php`, `$current_site` to be populated through `sunrise.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:
1. Add an action after the site lookup process, to allow setting defaults
on the globals or doing other actions.
2. Add a `ms_network_not_found` action into the `if ( 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.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/31702>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list