Make WordPress Core


Ignore:
Timestamp:
10/18/2022 06:14:01 PM (2 years ago)
Author:
davidbaumwald
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-network-query.php

    r54133 r54637  
    8787     *
    8888     * @since 4.6.0
    89      * @since 6.1.0 Introduced the 'update_network_meta_cache' parameter.
    9089     *
    9190     * @param string|array $query {
    9291     *     Optional. Array or query string of network query parameters. Default empty.
    9392     *
    94      *     @type int[]        $network__in                Array of network IDs to include. Default empty.
    95      *     @type int[]        $network__not_in            Array of network IDs to exclude. Default empty.
    96      *     @type bool         $count                      Whether to return a network count (true) or array of network objects.
    97      *                                                    Default false.
    98      *     @type string       $fields                     Network fields to return. Accepts 'ids' (returns an array of network IDs)
    99      *                                                    or empty (returns an array of complete network objects). Default empty.
    100      *     @type int          $number                     Maximum number of networks to retrieve. Default empty (no limit).
    101      *     @type int          $offset                     Number of networks to offset the query. Used to build LIMIT clause.
    102      *                                                    Default 0.
    103      *     @type bool         $no_found_rows              Whether to disable the `SQL_CALC_FOUND_ROWS` query. Default true.
    104      *     @type string|array $orderby                    Network status or array of statuses. Accepts 'id', 'domain', 'path',
    105      *                                                    'domain_length', 'path_length' and 'network__in'. Also accepts false,
    106      *                                                    an empty array, or 'none' to disable `ORDER BY` clause. Default 'id'.
    107      *     @type string       $order                      How to order retrieved networks. Accepts 'ASC', 'DESC'. Default 'ASC'.
    108      *     @type string       $domain                     Limit results to those affiliated with a given domain. Default empty.
    109      *     @type string[]     $domain__in                 Array of domains to include affiliated networks for. Default empty.
    110      *     @type string[]     $domain__not_in             Array of domains to exclude affiliated networks for. Default empty.
    111      *     @type string       $path                       Limit results to those affiliated with a given path. Default empty.
    112      *     @type string[]     $path__in                   Array of paths to include affiliated networks for. Default empty.
    113      *     @type string[]     $path__not_in               Array of paths to exclude affiliated networks for. Default empty.
    114      *     @type string       $search                     Search term(s) to retrieve matching networks for. Default empty.
    115      *     @type bool         $update_network_cache       Whether to prime the cache for found networks. Default true.
    116      *     @type bool         $update_network_meta_cache  Whether to prime the metadata (option) cache for found networks.
    117      *                                                    Default true.
     93     *     @type int[]        $network__in          Array of network IDs to include. Default empty.
     94     *     @type int[]        $network__not_in      Array of network IDs to exclude. Default empty.
     95     *     @type bool         $count                Whether to return a network count (true) or array of network objects.
     96     *                                              Default false.
     97     *     @type string       $fields               Network fields to return. Accepts 'ids' (returns an array of network IDs)
     98     *                                              or empty (returns an array of complete network objects). Default empty.
     99     *     @type int          $number               Maximum number of networks to retrieve. Default empty (no limit).
     100     *     @type int          $offset               Number of networks to offset the query. Used to build LIMIT clause.
     101     *                                              Default 0.
     102     *     @type bool         $no_found_rows        Whether to disable the `SQL_CALC_FOUND_ROWS` query. Default true.
     103     *     @type string|array $orderby              Network status or array of statuses. Accepts 'id', 'domain', 'path',
     104     *                                              'domain_length', 'path_length' and 'network__in'. Also accepts false,
     105     *                                              an empty array, or 'none' to disable `ORDER BY` clause. Default 'id'.
     106     *     @type string       $order                How to order retrieved networks. Accepts 'ASC', 'DESC'. Default 'ASC'.
     107     *     @type string       $domain               Limit results to those affiliated with a given domain. Default empty.
     108     *     @type string[]     $domain__in           Array of domains to include affiliated networks for. Default empty.
     109     *     @type string[]     $domain__not_in       Array of domains to exclude affiliated networks for. Default empty.
     110     *     @type string       $path                 Limit results to those affiliated with a given path. Default empty.
     111     *     @type string[]     $path__in             Array of paths to include affiliated networks for. Default empty.
     112     *     @type string[]     $path__not_in         Array of paths to exclude affiliated networks for. Default empty.
     113     *     @type string       $search               Search term(s) to retrieve matching networks for. Default empty.
     114     *     @type bool         $update_network_cache Whether to prime the cache for found networks. Default true.
    118115     * }
    119116     */
    120117    public function __construct( $query = '' ) {
    121118        $this->query_var_defaults = array(
    122             'network__in'               => '',
    123             'network__not_in'           => '',
    124             'count'                     => false,
    125             'fields'                    => '',
    126             'number'                    => '',
    127             'offset'                    => '',
    128             'no_found_rows'             => true,
    129             'orderby'                   => 'id',
    130             'order'                     => 'ASC',
    131             'domain'                    => '',
    132             'domain__in'                => '',
    133             'domain__not_in'            => '',
    134             'path'                      => '',
    135             'path__in'                  => '',
    136             'path__not_in'              => '',
    137             'search'                    => '',
    138             'update_network_cache'      => true,
    139             'update_network_meta_cache' => true,
     119            'network__in'          => '',
     120            'network__not_in'      => '',
     121            'count'                => false,
     122            'fields'               => '',
     123            'number'               => '',
     124            'offset'               => '',
     125            'no_found_rows'        => true,
     126            'orderby'              => 'id',
     127            'order'                => 'ASC',
     128            'domain'               => '',
     129            'domain__in'           => '',
     130            'domain__not_in'       => '',
     131            'path'                 => '',
     132            'path__in'             => '',
     133            'path__not_in'         => '',
     134            'search'               => '',
     135            'update_network_cache' => true,
    140136        );
    141137
     
    248244        $_args = wp_array_slice_assoc( $this->query_vars, array_keys( $this->query_var_defaults ) );
    249245
    250         // Ignore these arguments, as the queried result will be the same regardless.
    251         unset( $_args['fields'], $_args['update_network_cache'], $_args['update_network_meta_cache'] );
     246        // Ignore the $fields, $update_network_cache arguments as the queried result will be the same regardless.
     247        unset( $_args['fields'], $_args['update_network_cache'] );
    252248
    253249        $key          = md5( serialize( $_args ) );
     
    291287
    292288        if ( $this->query_vars['update_network_cache'] ) {
    293             _prime_network_caches( $network_ids, $this->query_vars['update_network_meta_cache'] );
     289            _prime_network_caches( $network_ids );
    294290        }
    295291
Note: See TracChangeset for help on using the changeset viewer.