Commit Graph

193 Commits

Author SHA1 Message Date
Felix Arntz
18789739c1 Multisite: Revert [41719].
While `get_site_by()` makes sense as a more explicit and less complex replacement for `get_blog_details()`, it is not ready yet in terms of caching, where it currently falls short of the older function under specific circumstances.

See #40180, #40228.

Built from https://develop.svn.wordpress.org/trunk@41883


git-svn-id: http://core.svn.wordpress.org/trunk@41717 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-10-16 22:29:48 +00:00
John Blackbourn
b25e759621 Networks and Sites: Correct the documentation for the update_site_cache parameter of WP_Site_Query.
Props welcher, sudar
Fixes #42155

Built from https://develop.svn.wordpress.org/trunk@41795


git-svn-id: http://core.svn.wordpress.org/trunk@41629 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-10-09 14:26:49 +00:00
Jeremy Felt
018a94d5f5 Multisite: Use get_site_by() in get_id_from_blogname().
Fixes #42091.

Built from https://develop.svn.wordpress.org/trunk@41743


git-svn-id: http://core.svn.wordpress.org/trunk@41577 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-10-04 18:45:52 +00:00
Felix Arntz
29e5ad5528 Multisite: Improve get_blog_details() by using get_site_by().
`get_site_by()` is now the preferred way to retrieve a site object by lookup for identifying data. By using a coherent structure and `get_sites()` internally, it has several advantages over the direct database queries and complex code in `get_blog_details()`. Therefore `get_blog_details()` is now a wrapper for `get_site_by()`, providing backward compatibility fixes where necessary.

Unit tests have been adjusted to account for the `blog-details` and `blog-lookup` cache groups, which are no longer needed.

Props spacedmonkey, jeremyfelt, flixos90.
Fixes #40228.

Built from https://develop.svn.wordpress.org/trunk@41719


git-svn-id: http://core.svn.wordpress.org/trunk@41553 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-10-03 19:40:46 +00:00
Felix Arntz
1130241bbd Multisite: Replace calls to refresh_blog_details() with clean_blog_cache().
Fixes #42077. See #40201.

Built from https://develop.svn.wordpress.org/trunk@41717


git-svn-id: http://core.svn.wordpress.org/trunk@41551 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-10-03 19:05:46 +00:00
Felix Arntz
a9b8f70682 Multisite: Establish clean_blog_cache() as a replacement for refresh_blog_details().
Going forward, `clean_blog_cache()` is recommended to be used instead of `refresh_blog_details()`. It has been adjusted to match the functionality of the latter, with the exception that it always requires a site ID or object to be passed. The `refresh_blog_details` action has been deprecated in favor of the `clean_site_cache` action. The function itself is not formally deprecated at this point, but will likely be in the near future.

Props spacedmonkey.
Fixes #40201.

Built from https://develop.svn.wordpress.org/trunk@41716


git-svn-id: http://core.svn.wordpress.org/trunk@41550 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-10-03 18:41:48 +00:00
Jeremy Felt
a580793b82 Multisite: Introduce get_site_by().
`get_site_by()` is a replacement for `get_blog_details()` that uses `WP_Site_Query` to retrieve specific sites based on a given field and value.

Props flixos90, spacedmonkey.
Fixes #40180.

Built from https://develop.svn.wordpress.org/trunk@41698


git-svn-id: http://core.svn.wordpress.org/trunk@41532 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-10-03 04:10:49 +00:00
Jeremy Felt
bdd50f28b4 Docs: Clarify docs for hooked count/date updates
See #41017.

Built from https://develop.svn.wordpress.org/trunk@41666


git-svn-id: http://core.svn.wordpress.org/trunk@41500 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-10-02 03:20:47 +00:00
Jeremy Felt
78880a6a0b Multisite: Only update a site's post count when post types of post are updated.
Previously, the query to update the count of published posts would run every time any post type transitioned between a `publish`/non-published status or was deleted.

Props sboisvert, JPry, spacedmonkey.
Fixes #42021.

Built from https://develop.svn.wordpress.org/trunk@41665


git-svn-id: http://core.svn.wordpress.org/trunk@41499 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-10-02 03:09:44 +00:00
Jeremy Felt
abdfe59c28 Multisite: Use get_current_blog_id() instead of $wpdb->blogid.
`get_current_blog_id()` is more appropriate for determining the ID of the current site in most cases. This eliminates the need for the global `$wpdb` in several functions and is better than the implicit global used in admin pages.

Props bnap00, spacedmonkey.
Fixes #41684.

Built from https://develop.svn.wordpress.org/trunk@41661


git-svn-id: http://core.svn.wordpress.org/trunk@41495 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-10-02 01:44:47 +00:00
Felix Arntz
0892a6ebbf Multisite: Improve initializing available roles when switch sites.
Switching the available roles and the current user's capabilities no longer happens in `switch_to_blog()` and `restore_current_blog()`, instead it has been moved to a new function `wp_switch_roles_and_user()` which is hooked into the site switching process. This allows to improve performance by temporarily unhooking the function when roles and capabilities do not need to be switched.

This change ensures that switching available roles now works closer to switching user capabilities, particularly the changes in [41624]. A new `WP_Roles::for_site( $site_id )` method has been introduced, and the `WP_Roles::_init()` method has been deprecated. It is furthermore possible to retrieve the site ID for which the available roles are currently initialized through a new `WP_Roles::get_site_id()`.

Props johnjamesjacoby, flixos90.
Fixes #38645.

Built from https://develop.svn.wordpress.org/trunk@41625


git-svn-id: http://core.svn.wordpress.org/trunk@41460 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-09-27 21:44:44 +00:00
Felix Arntz
21f18c2d30 Multisite: Initialize a user's roles correctly when setting them up for a different site.
While it has always been possible to initialize a user's roles and capabilities for another site than the current one in a multisite, the actual roles available were not switched prior to this change, possibly causing invalid roles to show up or actually valid capabilities not being available.

In order to fix this bug in a clean way, relevant parts of the `WP_User` class have been refactored. The ID of the site for which capabilities are currently initialized are now stored in a private property `WP_User::$site_id`. The `WP_User::for_blog( $blog_id )` and `WP_User::_init_caps( $cap_key )` methods have been deprecated in favor of `WP_User::for_site( $site_id )`. In addition, a new method `WP_User::get_site_id()` has been introduced to retrieve the site ID for which the user's capabilities are currently initialized.

Props ryanduff, jeremyfelt, flixos90.
Fixes #36961.

Built from https://develop.svn.wordpress.org/trunk@41624


git-svn-id: http://core.svn.wordpress.org/trunk@41459 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-09-27 21:10:45 +00:00
Jeremy Felt
560d705b00 Multisite: Update docs for switch_to_blog().
As of [21403], autoload options are switched along with the cache key prefix.

Props stevepuddick.
Fixes #41815.

Built from https://develop.svn.wordpress.org/trunk@41373


git-svn-id: http://core.svn.wordpress.org/trunk@41206 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-09-12 03:34:48 +00:00
Dominik Schilling
2526eb2d86 Multisite: Clarify return type of get_sites() when 'count' is passed as a query var.
Fixes #41789.
Built from https://develop.svn.wordpress.org/trunk@41331


git-svn-id: http://core.svn.wordpress.org/trunk@41162 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-09-04 08:16:44 +00:00
Felix Arntz
473e1ba73b Multisite: Remove references to $wpdb->siteid and use get_current_network_id() instead.
Props sathyapulse, spacedmonkey.
Fixes #41507.

Built from https://develop.svn.wordpress.org/trunk@41242


git-svn-id: http://core.svn.wordpress.org/trunk@41082 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-08-12 13:11:43 +00:00
Drew Jaynes
0401cee8b3 Docs: Reduce confusion in @since MU notationss by indicating the WP version (3.0.0) the code was merged into core while retaining the original context.
Props sathyapulse.
Fixes #41509.

Built from https://develop.svn.wordpress.org/trunk@41200


git-svn-id: http://core.svn.wordpress.org/trunk@41040 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-08-01 20:44:43 +00:00
Jeremy Felt
3d4f2f2fea Multisite: Correct documentation for site status change hooks.
Props johnbillion.
Fixes #40287.

Built from https://develop.svn.wordpress.org/trunk@40352


git-svn-id: http://core.svn.wordpress.org/trunk@40259 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-03-30 04:36:43 +00:00
Jeremy Felt
1c6111f3bb Multisite: Remove unused site-lookup global cache group.
The `site-lookup` group was introduced in WPMU, but never actually used in WordPress core.

Props johnjamesjacoby.
Fixes #38725.

Built from https://develop.svn.wordpress.org/trunk@40347


git-svn-id: http://core.svn.wordpress.org/trunk@40254 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-03-28 21:08:47 +00:00
Jeremy Felt
0e7e0aa4bc Multisite: Respect $_wp_suspend_cache_invalidation when clearing network and site caches.
Props johnjamesjacoby.
Fixes #40028.

Built from https://develop.svn.wordpress.org/trunk@40346


git-svn-id: http://core.svn.wordpress.org/trunk@40253 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-03-28 19:36:49 +00:00
Jeremy Felt
f940beae2b Multisite: Add lang_id support to WP_Site_Query.
Sites can now be queried by `lang_id`, `lang__in`, and `lang__not_in`.

Props ocean90.
Fixes #40196.

Built from https://develop.svn.wordpress.org/trunk@40340


git-svn-id: http://core.svn.wordpress.org/trunk@40247 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-03-27 19:48:52 +00:00
Pascal Birchler
6216c997ba Multisite: After [40305], rename clean_site_details_cache() method as it's not really private.
See #40063.


Built from https://develop.svn.wordpress.org/trunk@40333


git-svn-id: http://core.svn.wordpress.org/trunk@40240 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-03-25 15:31:43 +00:00
Felix Arntz
cde6126923 Multisite: Handle sites cache invalidation more granularly for option updates.
Previously `update_blog_option()` would trigger an invalidation of that site's entire cache although these changes did not affect the content of these caches. Furthermore changes to the special options `blogname`, `siteurl` and `post_count` should not invalidate the entire cache of that site, but only their respective site details cache. The option `home` now has the same behavior as it also belongs to the site details, but did not invalidate the cache at all previously.

Several new unit tests confirm these changes work as expected.

Fixes #40063.

Built from https://develop.svn.wordpress.org/trunk@40305


git-svn-id: http://core.svn.wordpress.org/trunk@40212 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-03-19 16:22:45 +00:00
Gary Pendergast
e79fa03329 Roles/Capabilities: Add a new wp_roles_init filter.
Historically, it's been difficult to extend user roles, but reasonable to work around by waiting until after `init` has fired, to add custom roles and capabilities. With the addition of Locale Switching, Core now potentially loads roles before `init` has fired, leaving a window where custom roles and capabilities are not handled.

The new filter allows plugins to add their own custom roles whenever they're initialised (on page load, or when switching sites, for example), so that they can always be obeyed.

`WP_Roles` has also been tidied up a little bit, to remove duplicate code.

Props johnjamesjacoby, pento.
Fixes #23016.


Built from https://develop.svn.wordpress.org/trunk@39082


git-svn-id: http://core.svn.wordpress.org/trunk@39024 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-11-02 00:31:32 +00:00
Jeremy Felt
555466ab82 Multisite: Replace get_blog_details() in inline documentation.
Some documentation is now out of date and some can be replaced with a mention of `get_site()`.

Fixes #37102.

Built from https://develop.svn.wordpress.org/trunk@38943


git-svn-id: http://core.svn.wordpress.org/trunk@38886 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-10-26 03:39:29 +00:00
Jeremy Felt
a545afb331 Multisite: Deprecate the blog_details filter.
`get_site()` has replaced `get_blog_details()` throughout core and is the recommended way to retrieve a current or single site object.

The `blog_details` filter is applied when full details are requested from `get_blog_details()`.

To ensure backwards compatibility in the switch to `get_site()`, this `blog_details` filter is now applied in `WP_Site::get_details()` and marked as deprecated with a note to rely instead on the `site_details` filter introduced in 4.6.

Props flixos90.
See #37102.
Fixes #38491.

Built from https://develop.svn.wordpress.org/trunk@38936


git-svn-id: http://core.svn.wordpress.org/trunk@38879 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-10-25 23:44:30 +00:00
Jeremy Felt
680f14fcd1 Multisite: Replace get_blog_details() in wp-includes/ms-blogs.php with get_site().
Props flixos90.
See #37102.
Fixes #38351.

Built from https://develop.svn.wordpress.org/trunk@38915


git-svn-id: http://core.svn.wordpress.org/trunk@38858 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-10-25 18:50:30 +00:00
Jeremy Felt
1560fbcbc5 Multisite: Use get_network() and get_current_network_id() for current network data.
`get_network()` falls back to the current network when called without any arguments. Between this and `get_current_network_id()`, we can replace almost all instances of the global `$current_site` and all instances of `get_current_site()`.

This effectively deprecates `get_current_site()`, something that we'll do in a future ticket.

Props flixos90.
Fixes #37414.

Built from https://develop.svn.wordpress.org/trunk@38814


git-svn-id: http://core.svn.wordpress.org/trunk@38757 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-10-19 04:47:30 +00:00
Jeremy Felt
b5d68be194 Multisite: Use get_sites() instead of a database lookup in get_id_from_blogname().
Because queries generated via `get_sites()` are cached, we can remove the `get_id_from_blogname` cache key.

Props flixos90.
Fixes #38175.

Built from https://develop.svn.wordpress.org/trunk@38659


git-svn-id: http://core.svn.wordpress.org/trunk@38602 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-09-27 18:18:28 +00:00
Jeremy Felt
7fe5b6d182 Multisite: Handle get_id_from_blogname() lookups when the network domain has www..
Previously, if a network's domain started with `www.` in a subdomain configuration, a slug lookup with `get_id_from_blogname()` would not match an existing site. A similar lookup in a subdirectory configuration would work fine.

This strips `www.` from the network's domain in a subdomain configuration during the lookup and returns the site as expected.

Adds tests which would previously fail in a subdomain configuration, but now pass in both configurations.

Props igmoweb, flixos90.
Fixes #34450.

Built from https://develop.svn.wordpress.org/trunk@38658


git-svn-id: http://core.svn.wordpress.org/trunk@38601 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-09-27 17:57:30 +00:00
Jeremy Felt
58f107fa95 Multisite: Revert [38388].
Restore `get_current_site()` to a multisite only function. Providing this in single site may be a possibility in the future, but should have a dedicated ticket and discussion.

See #37699.

Built from https://develop.svn.wordpress.org/trunk@38636


git-svn-id: http://core.svn.wordpress.org/trunk@38579 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-09-20 21:39:29 +00:00
Sergey Biryukov
b434cda3a6 Docs: Synchronize docblocks for WP_Site_Query::__construct() and get_sites() after the changes in [37735], [38008], [38103], and [38336].
Props MaximeCulea.
Fixes #38039.
Built from https://develop.svn.wordpress.org/trunk@38596


git-svn-id: http://core.svn.wordpress.org/trunk@38539 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-09-13 13:20:35 +00:00
Sergey Biryukov
1cdb4b52af Docs: Correct description for domain and path arguments in WP_Network_Query::__construct().
See #32504.
Built from https://develop.svn.wordpress.org/trunk@38595


git-svn-id: http://core.svn.wordpress.org/trunk@38538 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-09-13 13:10:32 +00:00
Scott Taylor
e5225324a2 Multisite: use get_current_blog_id() where applicable, in lieu of plucking the $blog_id global from outer space.
See #37699.

Built from https://develop.svn.wordpress.org/trunk@38457


git-svn-id: http://core.svn.wordpress.org/trunk@38398 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-08-31 04:55:54 +00:00
Scott Taylor
08233c6aff Multisite: move get_current_site() to load.php so that it can be used in more places, instead of importing global $current_site.
See #37699.

Built from https://develop.svn.wordpress.org/trunk@38388


git-svn-id: http://core.svn.wordpress.org/trunk@38329 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-08-26 21:35:30 +00:00
Jeremy Felt
eaffe99260 Multisite: Remove unnecessary reference parameters.
There is no advantage to passing parameters by reference to `get_site()`, `get_network()`, and `update_site_cache()`.

Props flixos90, ocean90 for review.
See #37615.

Built from https://develop.svn.wordpress.org/trunk@38232


git-svn-id: http://core.svn.wordpress.org/trunk@38173 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-08-09 18:12:31 +00:00
Jeremy Felt
b45adc74df Multisite: Use get_current_blog_id() in get_site() for current site.
The global `$current_blog` is not switched in `switch_to_blog()` and can
not be used to properly retrieve current switched site information.

See #37607.

Built from https://develop.svn.wordpress.org/trunk@38217


git-svn-id: http://core.svn.wordpress.org/trunk@38158 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-08-08 22:33:28 +00:00
Drew Jaynes
e6267dcf19 Docs: Fix formatting, tense, verb conjugation, and other syntax for wp-includes/* elements introduced or changed in 4.6.
Part 2/2.

Fixes #37318.

Built from https://develop.svn.wordpress.org/trunk@38125


git-svn-id: http://core.svn.wordpress.org/trunk@38066 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-07-20 19:33:30 +00:00
Drew Jaynes
e3e4762b8f Docs: Update the default value for the optional $args parameter in get_networks() following [38042].
See #32504.

Built from https://develop.svn.wordpress.org/trunk@38055


git-svn-id: http://core.svn.wordpress.org/trunk@37996 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-07-13 16:04:29 +00:00
Jeremy Felt
f3b3ece76a Multisite: Set default $args to an empty array in get_networks().
The empty string was not incorrect. Using `array()` here instead makes things a bit more consistent by aligning with `get_sites()`, `get_users()`, and `get_terms()`.

See #32504.

Built from https://develop.svn.wordpress.org/trunk@38042


git-svn-id: http://core.svn.wordpress.org/trunk@37983 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-07-13 05:30:29 +00:00
Sergey Biryukov
139387b7e5 Docs: Use 3-digit, x.x.x-style semantic versioning for _doing_it_wrong(), _deprecated_function(), _deprecated_argument(), and _deprecated_file() throughout core.
Props metodiew.
Fixes #36495.
Built from https://develop.svn.wordpress.org/trunk@37985


git-svn-id: http://core.svn.wordpress.org/trunk@37926 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-07-06 12:40:29 +00:00
Jeremy Felt
f4d46f0235 Multisite: Revert [37874].
After [37923], `get_blog_details()` contained a now unnecessary attempt at back-compat for objects stored in cache.

See #36717.

Built from https://develop.svn.wordpress.org/trunk@37929


git-svn-id: http://core.svn.wordpress.org/trunk@37870 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-06-30 16:40:28 +00:00
Jeremy Felt
b077123a98 Multisite: Lazy load extended WP_Site properties when requested.
In the past, `get_blog_details()` has been used to retrieve the `home`, `siteurl`, `blogname`, and `post_count` options for a site. By lazy loading properties in a `WP_Site` object, we can avoid having to use `get_blog_details()` and instead provide the properties as needed.

This introduces the global `site-details` cache group in which standard objects representing the site are stored. This will one day be a replacement for the `blog-details` cache group that is currently used in `get_blog_details()`.

This relies on the `ms_loaded` action introduced in [37916] as properties are not available via `get_option()` until multisite has been fully loaded.

Props flixos90.
Fixes #36935.

Built from https://develop.svn.wordpress.org/trunk@37918


git-svn-id: http://core.svn.wordpress.org/trunk@37859 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-06-29 19:32:27 +00:00
Jeremy Felt
b99a31d35c Multisite: Introduce get_networks().
`get_networks()` is a wrapper for `WP_Network_Query`.

Props flixos90.
See #32504.

Built from https://develop.svn.wordpress.org/trunk@37895


git-svn-id: http://core.svn.wordpress.org/trunk@37836 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-06-28 21:28:29 +00:00
Jeremy Felt
f111fdb69a Multisite: Introduce WP_Network_Query.
Provides a consistent way to query `$wpdb->site` for `WP_Network` objects based on domain, path, network ID, and (main) site ID.

Introduces and uses update_network_cache() and _prime_network_caches() to maintain a cached list of WP_Network objects for use in multiple queries.

Props flixos90.
See #32504.

Built from https://develop.svn.wordpress.org/trunk@37894


git-svn-id: http://core.svn.wordpress.org/trunk@37835 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-06-28 21:27:30 +00:00
Jeremy Felt
5d478fbe5e Multisite: Introduce get_network().
Given a network ID or network object, `get_network()` retrieves network data in the same vein as `get_site()` or `get_post()`. This will allow for clean retrieval of networks from a primed cache when `WP_Network_Query` is implemented.

Props flixos90.
See #32504.

Built from https://develop.svn.wordpress.org/trunk@37893


git-svn-id: http://core.svn.wordpress.org/trunk@37834 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-06-28 21:18:30 +00:00
Jeremy Felt
9edd8df844 Multisite: Clear incomplete objects from cache in get_blog_details() when found.
In [37657], the `blog_id` and `site_id` properties were changed to private. Any `WP_Site` objects previously stored in cache with public properties should now be considered invalid. We can detect this by checking for these missing properties and clearing the dirty cache if found.

Props flixos90.
Fixes #36717.

Built from https://develop.svn.wordpress.org/trunk@37874


git-svn-id: http://core.svn.wordpress.org/trunk@37815 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-06-26 14:29:28 +00:00
Drew Jaynes
6bb600fe25 Docs: Update the documentation for get_site() and the get_site filter following the removal of the $output parameter in [37652].
Props flixos90.
See #35791.

Built from https://develop.svn.wordpress.org/trunk@37699


git-svn-id: http://core.svn.wordpress.org/trunk@37665 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-06-14 18:14:27 +00:00
Jeremy Felt
75a851a3aa Multisite: Remove the output parameter from get_site()
Full `WP_Site` objects should be expected from `get_site()` rather than arrays.

In the single (soon to be deprecated) use of arrays for this in core, we can cast the result to `(array)` for back-compat.

See #35791.

Built from https://develop.svn.wordpress.org/trunk@37652


git-svn-id: http://core.svn.wordpress.org/trunk@37618 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-06-08 02:48:30 +00:00
Jeremy Felt
a6de56b473 Multisite: Bump last_changed cache on site update and creation
When a site is added, updated, or deleted, the `site_ids` cache for a query will no longer be reliable. Bumping `last_changed` will force a new query for site IDs.

See #35791.

Built from https://develop.svn.wordpress.org/trunk@37618


git-svn-id: http://core.svn.wordpress.org/trunk@37586 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-06-02 00:59:27 +00:00
Jeremy Felt
8dd52fb458 Multisite: Introduce get_sites()
`get_sites()` is a wrapper for `WP_Site_Query`.

Props spacedmonkey, DrewAPicture.
See #35791.

Built from https://develop.svn.wordpress.org/trunk@37616


git-svn-id: http://core.svn.wordpress.org/trunk@37584 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-06-01 23:21:27 +00:00
Boone Gorges
1f2635d52b Make the 'comment' cache group persistent.
'comment' was made non-persistent in [7986], to address the difficulty of
reliable cache invalidation. Since then, the comment system has improved such
that we can be more confident that caches are being busted as needed.

Props spacedmonkey.
Fixes #36906.
Built from https://develop.svn.wordpress.org/trunk@37613


git-svn-id: http://core.svn.wordpress.org/trunk@37581 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-06-01 21:26:27 +00:00
Drew Jaynes
9cb5247392 Docs: Standardize filter docs in remaining wp-includes/* files to use third-person singular verbs per the inline documentation standards for PHP.
See #36913.

Built from https://develop.svn.wordpress.org/trunk@37518


git-svn-id: http://core.svn.wordpress.org/trunk@37486 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-05-22 18:50:28 +00:00
Jeremy Felt
2dd1e72f10 Multisite: Introduce WP_Site_Query
Provides a consistent way to query `$wpdb->blogs` for `WP_Site` objects based on domain, path, site ID, network ID, and more.

Introduces and uses `update_site_cache()` and `_prime_site_caches()` to maintain a cached list of `WP_Site` objects for use in multiple queries.

Props spacedmonkey, flixos90, DrewAPicture, jeremyfelt, ocean90.
See #35791.

Built from https://develop.svn.wordpress.org/trunk@37477


git-svn-id: http://core.svn.wordpress.org/trunk@37445 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-05-20 22:04:27 +00:00
Jeremy Felt
9fa38fdc31 Multisite: Introduce get_site()
Given a site ID or site object, `get_site()` retrieves site data in the same vein as `get_post()` or `get_comment()`. This will allow for clean retrieval of sites from a primed cache when `WP_Site_Query` is implemented.

Adds a `WP_Site::to_array()` method to support multiple return types within `get_site()`.

Props spacedmonkey.
See #35791.

Built from https://develop.svn.wordpress.org/trunk@37468


git-svn-id: http://core.svn.wordpress.org/trunk@37436 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-05-20 04:41:27 +00:00
Jeremy Felt
8d5c62b923 Multisite: Fire a clean_site_cache action when a site's cache is cleared
Props spacedmonkey.
Fixes #36203.

Built from https://develop.svn.wordpress.org/trunk@37204


git-svn-id: http://core.svn.wordpress.org/trunk@37170 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-04-14 04:19:27 +00:00
Jeremy Felt
ba65ad94f2 Docs: Update param/return types for WP_Site in ms-blogs.php
* `get_blog_details()` now returns a `WP_Site` object.
* `clean_blog_cache()` is now called with a `WP_Site` object.

See #32450.

Built from https://develop.svn.wordpress.org/trunk@36894


git-svn-id: http://core.svn.wordpress.org/trunk@36861 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-03-09 07:42:26 +00:00
Eric Lewis
22467e840f Networks and sites: Replace "blog" usage with "site" in docs.
Multisite functions use the term "blog" to refer to what we now call a "site," e.g. `get_current_blog_id()`. These functions are here to stay because of our commitment to backwards compatibility. What we can do is set the documentation straight.

See #35417.

Built from https://develop.svn.wordpress.org/trunk@36416


git-svn-id: http://core.svn.wordpress.org/trunk@36383 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-01-28 03:35:27 +00:00
Dominik Schilling
e8cc1b5a32 Multisite: Add the global cache group sites to restore_current_blog() and wp_start_object_cache().
See #32450.
Built from https://develop.svn.wordpress.org/trunk@36413


git-svn-id: http://core.svn.wordpress.org/trunk@36380 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-01-27 13:51:26 +00:00
Dominik Schilling
87b5e06838 Multisite: Add the global cache group networks to restore_current_blog().
Missed in [36258].

See #35251.
Built from https://develop.svn.wordpress.org/trunk@36411


git-svn-id: http://core.svn.wordpress.org/trunk@36378 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-01-27 13:43:28 +00:00
Jeremy Felt
0b69f2cd63 Multisite: Introduce the WP_Site class.
* A `WP_Site` object initially matches a row from `wp_blogs`.
* A site can be retrieved by its ID through `WP_Site::get_instance()`.
* Adds `sites` to the global cache group and captures instance lookups.
* The multisite bootstrap now ensures `$current_blog` is an instance of `WP_Site`.

Props johnjamesjacoby, jeremyfelt.
See #32450.

Built from https://develop.svn.wordpress.org/trunk@36393


git-svn-id: http://core.svn.wordpress.org/trunk@36360 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-01-25 21:51:26 +00:00
Dion Hulse
abbcc01542 Multisite: The networks group should be global.
Fixes #35251.

Built from https://develop.svn.wordpress.org/trunk@36258


git-svn-id: http://core.svn.wordpress.org/trunk@36225 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-01-11 05:04:26 +00:00
John Blackbourn
a5d44337b2 Docs: @param fixes for a variety of docblocks.
See #32246

Built from https://develop.svn.wordpress.org/trunk@36232


git-svn-id: http://core.svn.wordpress.org/trunk@36199 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-01-09 01:45:26 +00:00
John Blackbourn
8cbd79e3dc Ensure that the scheme used in the URL returned by get_blogaddress_by_id() always reflects the blog's URL, instead of using http.
Props thomaswm
Fixes #14867

Built from https://develop.svn.wordpress.org/trunk@35446


git-svn-id: http://core.svn.wordpress.org/trunk@35410 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-30 02:02:24 +00:00
Drew Jaynes
217b661703 Docs: Add missing descriptions for the $wpdb global in DocBlocks all the places.
See #32246.

Built from https://develop.svn.wordpress.org/trunk@35170


git-svn-id: http://core.svn.wordpress.org/trunk@35136 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-14 23:44:25 +00:00
Scott Taylor
4d26d999ce Fix doc blocks for ms-*.php files.
A few functions can return a conditional instead of an `if`/`else` of `true`/`false`.

See #32444.

Built from https://develop.svn.wordpress.org/trunk@32611


git-svn-id: http://core.svn.wordpress.org/trunk@32581 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-05-26 21:51:31 +00:00
Andrew Nacin
fd70baf919 Remove leading space from the definition of a global cache group.
This only applied in a rare situation during the switch_to_blog() process where no global groups were currently defined.

see #31243.

Built from https://develop.svn.wordpress.org/trunk@31348


git-svn-id: http://core.svn.wordpress.org/trunk@31329 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-02-06 03:26:22 +00:00
Andrew Nacin
116d1d354e Add useremail and userslugs as global cache groups. fixes #31243.
Built from https://develop.svn.wordpress.org/trunk@31347


git-svn-id: http://core.svn.wordpress.org/trunk@31328 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-02-06 03:24:23 +00:00
Jeremy Felt
8d55b418ec Don't overcheck the expected return from get_blog_details() in get_blogaddress_by_id()
If `get_blog_details()` is returning something that is not our expected object or `false`, then a notice would already be thrown there.

Also adds proper return docs to `get_blog_details()`.

Props SergeyBiryukov.

Fixes #30566

Built from https://develop.svn.wordpress.org/trunk@31178


git-svn-id: http://core.svn.wordpress.org/trunk@31159 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-01-14 05:33:25 +00:00
Jeremy Felt
8f35b191db Use a less complex approach for enforcing path slashes in update_blog_details()
Ensure leading and traling slashes are in place and don't touch anything in the middle. Validating with `array_filter()` would have missed a possible valid falsy path - `/my-path/0/`.

Props nacin.

Fixes #18117.

Built from https://develop.svn.wordpress.org/trunk@31158


git-svn-id: http://core.svn.wordpress.org/trunk@31139 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-01-12 04:21:22 +00:00
Jeremy Felt
343a6587cf Check for existence of data from get_blogaddress_by_id() before returning a URL
* Prevent a notice when an invalid ID is used with `get_blogaddres_by_id()`.
* Return a falsy empty string rather than the previous "http://".
* Add unit tests for `get_blogaddress_by_id()`.

Props nerrad.

Fixes #30566.

Built from https://develop.svn.wordpress.org/trunk@31157


git-svn-id: http://core.svn.wordpress.org/trunk@31138 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-01-12 02:24:22 +00:00
Jeremy Felt
eaf7f8df74 Enforce leading and trailing slashes on paths updated with update_blog_details()
In multisite, core expects the stored value for a site's path to have leading and trailing slashes. When these slashes are missing, it becomes impossible to visit the site.

This enforces proper `/path/` creation in `update_blog_details()`, most likely used when updating an existing site through `site-info.php`.

Props earnjam, simonwheatley.

Fixes #18117. Fixes #23865.

Built from https://develop.svn.wordpress.org/trunk@31155


git-svn-id: http://core.svn.wordpress.org/trunk@31136 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-01-12 01:43:22 +00:00
Drew Jaynes
bffe95d34c Docs Formatting: Backtick-escape inline code for all remaining dynamic hook docs in wp-includes/*.
Affects DocBlocks for the following hooks:
* `auth_post_meta_{$meta_key}`
* `term_links-$taxonomy`
* `customize_render_control_ . $this->id`
* `customize_render_panel_{$this->id}`
* `customize_render_section_{$this->id}`
* `customize_preview_{$this->id}`
* `customize_save_ . $this->id_data[ 'base' ]`
* `customize_update_ . $this->type`
* `customize_value_ . $this->id_data[ 'base' ]`
* `customize_sanitize_js_{$this->id}`
* `comment_form_field_{$name}`
* `comment_{$old_status}_to_{$new_status}`
* `comment_{$new_status}_{$comment->comment_type}`
* `extra_{$context}_headers`
* `get_template_part_{$slug}`
* `get_the_generator_{$type}`
* `get_{$adjacent}_post_join`
* `get_{$adjacent}_post_where`
* `get_{$adjacent}_post_sort`
* `{$adjacent}_post_rel_link`
* `{$adjacent}_post_link`
* `{$adjacent}_image_link`
* `blog_option_{$option}`
* `$permastructname . _rewrite_rules`
* `{$type}_template`
* `theme_mod_{$name}`
* `pre_set_theme_mod_$name`
* `current_theme_supports-{$feature}`
* `get_user_option_{$option}`
* `edit_user_{$field}`
* `pre_user_{$field}`
* `user_{$field}`

See #30552.

Built from https://develop.svn.wordpress.org/trunk@30656


git-svn-id: http://core.svn.wordpress.org/trunk@30646 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-11-30 12:10:23 +00:00
Sergey Biryukov
2d1cc72d7f Simplify the code for calling refresh_blog_details() whenever 'blogname', 'siteurl', or 'post_count' option is updated.
props pento, nacin.
fixes #26410.
Built from https://develop.svn.wordpress.org/trunk@29668


git-svn-id: http://core.svn.wordpress.org/trunk@29442 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-09-02 07:30:16 +00:00
Sergey Biryukov
8cc6ad5066 Check $post->post_status directly in _update_posts_count_on_delete() for better performance.
props pento.
fixes #27952.
Built from https://develop.svn.wordpress.org/trunk@29667


git-svn-id: http://core.svn.wordpress.org/trunk@29441 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-09-02 07:17:17 +00:00
Sergey Biryukov
0ae76229ec Use 3-digit x.x.x style for two 4.0.0 @since versions.
see #28885.
Built from https://develop.svn.wordpress.org/trunk@29319


git-svn-id: http://core.svn.wordpress.org/trunk@29100 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-07-29 00:59:16 +00:00
Sergey Biryukov
9c1d22a454 Avoid PHP notices in _count_posts_cache_key(), _update_blog_date_on_post_publish(), and _update_blog_date_on_post_delete() if post type is not registered.
props jesin.
fixes #28135.
Built from https://develop.svn.wordpress.org/trunk@29318


git-svn-id: http://core.svn.wordpress.org/trunk@29099 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-07-29 00:51:17 +00:00
Drew Jaynes
c5a59037f1 Inline documentation cleanup for 4.0 audit.
Various improvements:
* Adds `@see` reference for `wp_list_comments()` in 'wp_list_comments_args' filter docs, added in [28285]
* Various phpDoc tweaks for the 'run_wptexturize' filter docs, added in [28715]
* Sentence and wrapping changes for `is_https_url()`, added in [28894]
* Documents the `$args` parameter for `wp_dropdown_languages()`, added in [29007]
* Adds a period to the parameter description for `_update_posts_count_on_delete()`, added in [28835]
* Documents a global in `is_customize_preview()`, added in [28999]
* phpDoc tweaks, adds an access modifier for `wpdb::esc_like()`, added in [28711]

See #28885.

Built from https://develop.svn.wordpress.org/trunk@29163


git-svn-id: http://core.svn.wordpress.org/trunk@28947 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-07-14 01:02:15 +00:00
Scott Taylor
2e81419d4c In multisite, on the updated_option action, if the option name is one of: 'blogname', 'siteurl', 'post_count' - refresh the blog details cache for the current blog id.
Adds unit test.

Props kovshenin.
Fixes #26410.

Built from https://develop.svn.wordpress.org/trunk@28881


git-svn-id: http://core.svn.wordpress.org/trunk@28680 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-06-28 04:07:16 +00:00
Scott Taylor
0233933f22 get_blog_details()->post_count should update on more actions than just publish_post.
Adds unit test.

Props 5um17, midxcat, strangerstudios.
Fixes #27952.

Built from https://develop.svn.wordpress.org/trunk@28835


git-svn-id: http://core.svn.wordpress.org/trunk@28639 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-06-26 00:53:15 +00:00
Drew Jaynes
ac1701b7cc Fix the return description for switch_to_blog() to reflect that it always returns true.
Props jeremyfelt.
Fixes #25328.

Built from https://develop.svn.wordpress.org/trunk@27347


git-svn-id: http://core.svn.wordpress.org/trunk@27199 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-03-02 04:41:15 +00:00
Drew Jaynes
9e05dcc39b Inline documentation for hooks in wp-includes/ms-blogs.php.
Props miyauchi, kpdesign.
Fixes #25596.

Built from https://develop.svn.wordpress.org/trunk@26502


git-svn-id: http://core.svn.wordpress.org/trunk@26396 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-01 17:32:10 +00:00
Sergey Biryukov
74f77b85a6 Use get_current_site() instead of the $current_site global when possible.
props jeremyfelt.
fixes #25158.
Built from https://develop.svn.wordpress.org/trunk@26120


git-svn-id: http://core.svn.wordpress.org/trunk@26032 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-11-13 03:23:10 +00:00
Andrew Nacin
0e620877fd Use the wpdb method instead of $wpdb->prefix.
props hakre.
fixes #16756.

Built from https://develop.svn.wordpress.org/trunk@25615


git-svn-id: http://core.svn.wordpress.org/trunk@25532 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-09-24 23:41:10 +00:00
Sergey Biryukov
14308c0d41 Deprecate get_blogaddress_by_domain(), unused since [25261]. props jeremyfelt. fixes #25235.
Built from https://develop.svn.wordpress.org/trunk@25276


git-svn-id: http://core.svn.wordpress.org/trunk@25241 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-09-06 11:41:09 +00:00
Andrew Nacin
7554176da0 Return esc_url_raw(), not esc_url(), from get_blogaddress_by_domain(). props tlovett1, fixes #25057. #wcpvd
Built from https://develop.svn.wordpress.org/trunk@25033


git-svn-id: http://core.svn.wordpress.org/trunk@25020 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-08-16 19:42:09 +00:00
Sergey Biryukov
0d8d513a8d Fix typo in phpdoc. props belloswan. fixes #24217.
git-svn-id: http://core.svn.wordpress.org/trunk@24124 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-04-29 12:49:33 +00:00
Ryan Boren
0f304375f9 Fire the update_blog_public action from update_blog_status() instead of update_blog_public(). Pass blog ID and value to the action.
Add code to noindex() to sync the 'public' value in the site options table with the blog_public value in the options table.

fixes #23155


git-svn-id: http://core.svn.wordpress.org/trunk@23794 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-03-25 09:29:58 +00:00
Ryan Boren
57b2fc1c04 In refresh_blog_details(), make sure clean_blog_cache() gets the blog ID when the blog has been previously cached as non-existent. This ensures that -1 values in blog-details are cleared after blogs are created.
Props beezeee, hirozed
fixes #23405


git-svn-id: http://core.svn.wordpress.org/trunk@23752 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-03-19 05:05:19 +00:00
Peter Westwood
ffe2292a8f Multisite: Ensure that get_blogaddress_by_name does not mangle blognames with leading digits.
Correctly specify the backreference in the regular expression so that it can not become ambiguous when there is a leading digit on the blogname.

Fixes #23689 props dllh.


git-svn-id: http://core.svn.wordpress.org/trunk@23686 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-03-13 16:00:38 +00:00
Sergey Biryukov
69bd474ac6 Remove unused global reference. props aaroncampbell. fixes #23541.
git-svn-id: http://core.svn.wordpress.org/trunk@23458 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-02-20 00:18:15 +00:00
Helen Hou-Sandí
b1f1579604 its <=> it's in documentation, along with a rogue the, The, and looses. props trepmal. fixes #22665.
git-svn-id: http://core.svn.wordpress.org/trunk@23191 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2012-12-20 15:55:32 +00:00
Ryan Boren
06ee370814 Pinking shears
git-svn-id: http://core.svn.wordpress.org/trunk@22634 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2012-11-17 15:11:29 +00:00
Ryan Boren
05c40b9926 Sync actions between update_blog_details() and update_blog_status(). Add make_delete_blog and make_undelete_blog actions.
Props Kyrylo, wonderboymusic
fixes #20305


git-svn-id: http://core.svn.wordpress.org/trunk@22185 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2012-10-11 12:37:46 +00:00
Ryan Boren
7a86de87fb Reduce use of global. Use get_blog_details() instead. fixes #22090
git-svn-id: http://core.svn.wordpress.org/trunk@22108 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2012-10-04 12:40:09 +00:00
Ryan Boren
9fc9d42d0a * Register blog-id-cache group as global
* Introduce clean_blog_cache() so we can run it independently of refresh_blog_details() which assumes the blog still exists and get_blog_details() can be called.
* Don't db escape cache keys in get_blog_id_from_url()
* prepare() the query in get_blog_id_from_url()
* Return 0 for all failures in get_blog_id_from_url()
* clean_blog_cache() after dropping tables in wpmu_delete_blog() to make sure the cache is for real cleaned.



git-svn-id: http://core.svn.wordpress.org/trunk@22092 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2012-10-01 18:03:23 +00:00
Ryan Boren
75e64cface Reinit roles and the current user after switching the cache to the new blog in switch_to_blog() and restore_current_blog(). Props joostdekeijzer. fixes #21459
git-svn-id: http://core.svn.wordpress.org/trunk@22087 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2012-10-01 14:25:31 +00:00
Ryan Boren
7915172568 Don't read from the switched global. Instead use _wp_switched_stack. switched is retained for back compat and should not be directly read since it is prone to stompage by plugins. see #21459
git-svn-id: http://core.svn.wordpress.org/trunk@22015 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2012-09-26 17:02:44 +00:00
Ryan Boren
c57b0f836f * Invalidate the get_id_from_blogname_* cache in refresh_blog_details()
* Change $name to $slug in get_id_from_blogname() for some semblance of clarity.
* Strip leading and trailing slashes from the slug in get_id_from_blogname() so get_blog_details()->path can be passed directly.

Props wonderboymusic
see #20950


git-svn-id: http://core.svn.wordpress.org/trunk@21979 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2012-09-24 19:31:37 +00:00
Ryan Boren
1c44b15e63 Restore blog_option_* filter. see #21459
git-svn-id: http://core.svn.wordpress.org/trunk@21595 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2012-08-23 16:04:39 +00:00
Ryan Boren
f11317881a Resurrect the switched global. Some are still using it. see #21459
git-svn-id: http://core.svn.wordpress.org/trunk@21581 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2012-08-22 03:34:00 +00:00