Opened 14 years ago
Last modified 2 years ago
#14913 new defect (bug)
Multisite Requires Client Information to Load Files
Reported by: | filosofo | Owned by: | filosofo |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | normal | Version: | 3.1 |
Component: | Bootstrap/Load | Keywords: | has-patch needs-refresh |
Focuses: | multisite | Cc: |
Description
When installed as multi-site, WP in ms-settings.php
tries to parse the Host header request to determine which domain is requested. If none, it prints a redirecting Location header and exits.
This is problematic if you are loading WP but not using a client that sends headers to the server; for example, if you have another app on the same server that tries to include wp-load.php
directly.
Example:
<?php include '/path/to/wp/wp-load.php'; // let's do some stuff with WP programatically...
The above aborts in MS as it tries to redirect the nonexistent requesting client to the main blog's front page.
The problems I see with this:
wp-load.php
is supposed to provide a means of circumventing the template printing, so it shouldn't assume a typical browser client is making the requestwp-load.php
can be used this way on non-MS setups- In general, it's a bad jumble of MVC.
Currently I'm not sure what the best route is to fix this, but I will try to come back later with a solution.
Attachments (2)
Change History (18)
#2
@
14 years ago
The offending line is probably the header redirect here: http://core.trac.wordpress.org/browser/trunk/wp-includes/ms-settings.php#L98
Ran into this yesterday trying to execute via wp-load.php from the command line. HTTP_HOST wasn't set, though in this case, it might be set but is different from the main site, and therefore is causing a redirect.
#3
@
14 years ago
Perhaps we can cancel the redirect if WP_USE_THEMES
is false
? And set $current_blog
to the main one, regardless of the domain.
#4
@
12 years ago
- Keywords has-patch added; needs-patch removed
Patched - passes all multisite unit tests. Run this before / after patch:
php -r 'require( "wp-load.php" );'
#5
@
12 years ago
- Milestone changed from Future Release to 3.6
This works and still applies cleanly to trunk, passes Unit Tests
#7
@
11 years ago
Patch from @wonderboymusic still applied fine to trunk and tests still pass, but had a property change attached as well. Refreshed patch to be only wp-includes/ms-settings.php
in 14913.diff
#8
@
11 years ago
I'd love to see this in 3.7 - I recommend people use "require('wp-load'); do_action('whatever');" to run their backups via the shell/cron (and escape timeout issues) if they can - but this bug means that that advice is broken on multisite.
David
#9
@
11 years ago
I've reviewed the patch, and it looks good to me - it only affects the broken situation, and won't impact already-working situations. I've deployed it successfully and so has a client who needed this facility.
#11
@
11 years ago
- Focuses multisite removed
I'd love to see this in the next release... for one thing, this issue prevents command-line actions (e.g. command-line backups, thus escaping webserver timeouts) on multisite installs via a method like
<?php require('wp-load.php'); do_action('my_action'); ?>
To add to this, as it's somewhat related... It's impossible to execute wp-cron on multisite for ! is_main_site().