[wp-trac] [WordPress Trac] #27999: Problem with embedding WordPress Multisite in other PHP applications caused by path difference in ms-settings

WordPress Trac noreply at wordpress.org
Sat Sep 6 20:26:34 UTC 2014


#27999: Problem with embedding WordPress Multisite in other PHP applications caused
by path difference in ms-settings
-------------------------------------+------------------------------
 Reporter:  ivanbajalovic            |       Owner:
     Type:  defect (bug)             |      Status:  new
 Priority:  normal                   |   Milestone:  Awaiting Review
Component:  Networks and Sites       |     Version:  3.9
 Severity:  major                    |  Resolution:
 Keywords:  reporter-feedback close  |     Focuses:  multisite
-------------------------------------+------------------------------

Comment (by jeremyfelt):

 Hi @alexfurr, sorry to hear about the site troubles.

 Multisite is different from a single site installation in that it relies
 on the requested URL (by default) to determine what network and site to
 load from the database. This is the same when included from a different
 application. There are two ways around this.

 1. In the custom application, before loading `wp-load.php`, specify
 `$_SERVER['REQUEST_URI'] = '/path-to-lookup/';` so that WordPress knows
 how to direct the request. Something similar is done [https://github.com
 /wp-cli/wp-cli/blob/340ca491e30a67bba5ca35511033cf62b270b298/php/class-wp-
 cli.php#L114-L116 in WP-CLI] before [https://github.com/wp-cli/wp-
 cli/blob/340ca491e30a67bba5ca35511033cf62b270b298/php/WP_CLI/Runner.php#L594-L597
 loading WordPress].
 2. The alternative is to use a custom `sunrise.php` file in your `wp-
 content/` directory. This file allows any number of things to happen at
 the beginning of the WordPress multisite bootstrap process. The major use
 case for this file is to handle the lookup of site and network data so
 that WordPress will skip its own lookup process in `ms-settings.php`. IMO,
 this ends up being the more versatile solution as you can setup your
 `$current_site` and `$current_blog` data completely.

 Overall, while this process was tightened up in 3.9, I don't think it is a
 bug to fix as the behavior was not intentional before.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/27999#comment:7>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list