Networks and Sites: Revert the use of the metadata API for *_network_options functions.
[54080] refactored the logic in `get_network_option()`, `update_network_option()` and `delete_network_option()` to use the metadata API. However, this change resulted in issues with large multisite installs that utilize memcached having network options > 1MB in size. This change reverts [54080] and all related follow-up changes. Reverts [54080], [54081], and [54082]. Partially reverts [54267] and [54402]. Props pavelschoffer, rebasaurus, johnbillion, spacedmonkey, desrosj, rinatkhaziev. Fixes #56845. See #37181. Built from https://develop.svn.wordpress.org/trunk@54637 git-svn-id: http://core.svn.wordpress.org/trunk@54189 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
@@ -86,57 +86,53 @@ class WP_Network_Query {
|
||||
* Sets up the network query, based on the query vars passed.
|
||||
*
|
||||
* @since 4.6.0
|
||||
* @since 6.1.0 Introduced the 'update_network_meta_cache' parameter.
|
||||
*
|
||||
* @param string|array $query {
|
||||
* Optional. Array or query string of network query parameters. Default empty.
|
||||
*
|
||||
* @type int[] $network__in Array of network IDs to include. Default empty.
|
||||
* @type int[] $network__not_in Array of network IDs to exclude. Default empty.
|
||||
* @type bool $count Whether to return a network count (true) or array of network objects.
|
||||
* Default false.
|
||||
* @type string $fields Network fields to return. Accepts 'ids' (returns an array of network IDs)
|
||||
* or empty (returns an array of complete network objects). Default empty.
|
||||
* @type int $number Maximum number of networks to retrieve. Default empty (no limit).
|
||||
* @type int $offset Number of networks to offset the query. Used to build LIMIT clause.
|
||||
* Default 0.
|
||||
* @type bool $no_found_rows Whether to disable the `SQL_CALC_FOUND_ROWS` query. Default true.
|
||||
* @type string|array $orderby Network status or array of statuses. Accepts 'id', 'domain', 'path',
|
||||
* 'domain_length', 'path_length' and 'network__in'. Also accepts false,
|
||||
* an empty array, or 'none' to disable `ORDER BY` clause. Default 'id'.
|
||||
* @type string $order How to order retrieved networks. Accepts 'ASC', 'DESC'. Default 'ASC'.
|
||||
* @type string $domain Limit results to those affiliated with a given domain. Default empty.
|
||||
* @type string[] $domain__in Array of domains to include affiliated networks for. Default empty.
|
||||
* @type string[] $domain__not_in Array of domains to exclude affiliated networks for. Default empty.
|
||||
* @type string $path Limit results to those affiliated with a given path. Default empty.
|
||||
* @type string[] $path__in Array of paths to include affiliated networks for. Default empty.
|
||||
* @type string[] $path__not_in Array of paths to exclude affiliated networks for. Default empty.
|
||||
* @type string $search Search term(s) to retrieve matching networks for. Default empty.
|
||||
* @type bool $update_network_cache Whether to prime the cache for found networks. Default true.
|
||||
* @type bool $update_network_meta_cache Whether to prime the metadata (option) cache for found networks.
|
||||
* Default true.
|
||||
* @type int[] $network__in Array of network IDs to include. Default empty.
|
||||
* @type int[] $network__not_in Array of network IDs to exclude. Default empty.
|
||||
* @type bool $count Whether to return a network count (true) or array of network objects.
|
||||
* Default false.
|
||||
* @type string $fields Network fields to return. Accepts 'ids' (returns an array of network IDs)
|
||||
* or empty (returns an array of complete network objects). Default empty.
|
||||
* @type int $number Maximum number of networks to retrieve. Default empty (no limit).
|
||||
* @type int $offset Number of networks to offset the query. Used to build LIMIT clause.
|
||||
* Default 0.
|
||||
* @type bool $no_found_rows Whether to disable the `SQL_CALC_FOUND_ROWS` query. Default true.
|
||||
* @type string|array $orderby Network status or array of statuses. Accepts 'id', 'domain', 'path',
|
||||
* 'domain_length', 'path_length' and 'network__in'. Also accepts false,
|
||||
* an empty array, or 'none' to disable `ORDER BY` clause. Default 'id'.
|
||||
* @type string $order How to order retrieved networks. Accepts 'ASC', 'DESC'. Default 'ASC'.
|
||||
* @type string $domain Limit results to those affiliated with a given domain. Default empty.
|
||||
* @type string[] $domain__in Array of domains to include affiliated networks for. Default empty.
|
||||
* @type string[] $domain__not_in Array of domains to exclude affiliated networks for. Default empty.
|
||||
* @type string $path Limit results to those affiliated with a given path. Default empty.
|
||||
* @type string[] $path__in Array of paths to include affiliated networks for. Default empty.
|
||||
* @type string[] $path__not_in Array of paths to exclude affiliated networks for. Default empty.
|
||||
* @type string $search Search term(s) to retrieve matching networks for. Default empty.
|
||||
* @type bool $update_network_cache Whether to prime the cache for found networks. Default true.
|
||||
* }
|
||||
*/
|
||||
public function __construct( $query = '' ) {
|
||||
$this->query_var_defaults = array(
|
||||
'network__in' => '',
|
||||
'network__not_in' => '',
|
||||
'count' => false,
|
||||
'fields' => '',
|
||||
'number' => '',
|
||||
'offset' => '',
|
||||
'no_found_rows' => true,
|
||||
'orderby' => 'id',
|
||||
'order' => 'ASC',
|
||||
'domain' => '',
|
||||
'domain__in' => '',
|
||||
'domain__not_in' => '',
|
||||
'path' => '',
|
||||
'path__in' => '',
|
||||
'path__not_in' => '',
|
||||
'search' => '',
|
||||
'update_network_cache' => true,
|
||||
'update_network_meta_cache' => true,
|
||||
'network__in' => '',
|
||||
'network__not_in' => '',
|
||||
'count' => false,
|
||||
'fields' => '',
|
||||
'number' => '',
|
||||
'offset' => '',
|
||||
'no_found_rows' => true,
|
||||
'orderby' => 'id',
|
||||
'order' => 'ASC',
|
||||
'domain' => '',
|
||||
'domain__in' => '',
|
||||
'domain__not_in' => '',
|
||||
'path' => '',
|
||||
'path__in' => '',
|
||||
'path__not_in' => '',
|
||||
'search' => '',
|
||||
'update_network_cache' => true,
|
||||
);
|
||||
|
||||
if ( ! empty( $query ) ) {
|
||||
@@ -247,8 +243,8 @@ class WP_Network_Query {
|
||||
// $args can include anything. Only use the args defined in the query_var_defaults to compute the key.
|
||||
$_args = wp_array_slice_assoc( $this->query_vars, array_keys( $this->query_var_defaults ) );
|
||||
|
||||
// Ignore these arguments, as the queried result will be the same regardless.
|
||||
unset( $_args['fields'], $_args['update_network_cache'], $_args['update_network_meta_cache'] );
|
||||
// Ignore the $fields, $update_network_cache arguments as the queried result will be the same regardless.
|
||||
unset( $_args['fields'], $_args['update_network_cache'] );
|
||||
|
||||
$key = md5( serialize( $_args ) );
|
||||
$last_changed = wp_cache_get_last_changed( 'networks' );
|
||||
@@ -290,7 +286,7 @@ class WP_Network_Query {
|
||||
}
|
||||
|
||||
if ( $this->query_vars['update_network_cache'] ) {
|
||||
_prime_network_caches( $network_ids, $this->query_vars['update_network_meta_cache'] );
|
||||
_prime_network_caches( $network_ids );
|
||||
}
|
||||
|
||||
// Fetch full network objects from the primed cache.
|
||||
|
||||
Reference in New Issue
Block a user