Ticket #25344: 25344.9.patch
File 25344.9.patch, 31.0 KB (added by , 7 years ago) |
---|
-
src/wp-includes/class-wp-network-query.php
97 97 * @param string|array $query { 98 98 * Optional. Array or query string of network query parameters. Default empty. 99 99 * 100 * @type array $network__in Array of network IDs to include. Default empty. 101 * @type array $network__not_in Array of network IDs to exclude. Default empty. 102 * @type bool $count Whether to return a network count (true) or array of network objects. 103 * Default false. 104 * @type string $fields Network fields to return. Accepts 'ids' (returns an array of network IDs) 105 * or empty (returns an array of complete network objects). Default empty. 106 * @type int $number Maximum number of networks to retrieve. Default empty (no limit). 107 * @type int $offset Number of networks to offset the query. Used to build LIMIT clause. 108 * Default 0. 109 * @type bool $no_found_rows Whether to disable the `SQL_CALC_FOUND_ROWS` query. Default true. 110 * @type string|array $orderby Network status or array of statuses. Accepts 'id', 'domain', 'path', 111 * 'domain_length', 'path_length' and 'network__in'. Also accepts false, 112 * an empty array, or 'none' to disable `ORDER BY` clause. Default 'id'. 113 * @type string $order How to order retrieved networks. Accepts 'ASC', 'DESC'. Default 'ASC'. 114 * @type string $domain Limit results to those affiliated with a given domain. Default empty. 115 * @type array $domain__in Array of domains to include affiliated networks for. Default empty. 116 * @type array $domain__not_in Array of domains to exclude affiliated networks for. Default empty. 117 * @type string $path Limit results to those affiliated with a given path. Default empty. 118 * @type array $path__in Array of paths to include affiliated networks for. Default empty. 119 * @type array $path__not_in Array of paths to exclude affiliated networks for. Default empty. 120 * @type string $search Search term(s) to retrieve matching networks for. Default empty. 121 * @type bool $update_network_cache Whether to prime the cache for found networks. Default true. 100 * @type array $network__in Array of network IDs to include. Default empty. 101 * @type array $network__not_in Array of network IDs to exclude. Default empty. 102 * @type bool $count Whether to return a network count (true) or array of network objects. 103 * Default false. 104 * @type string $fields Network fields to return. Accepts 'ids' (returns an array of network IDs) 105 * or empty (returns an array of complete network objects). Default empty. 106 * @type int $number Maximum number of networks to retrieve. Default empty (no limit). 107 * @type int $offset Number of networks to offset the query. Used to build LIMIT clause. 108 * Default 0. 109 * @type bool $no_found_rows Whether to disable the `SQL_CALC_FOUND_ROWS` query. Default true. 110 * @type string|array $orderby Network status or array of statuses. Accepts 'id', 'domain', 'path', 111 * 'domain_length', 'path_length' and 'network__in'. Also accepts false, 112 * an empty array, or 'none' to disable `ORDER BY` clause. Default 'id'. 113 * @type string $order How to order retrieved networks. Accepts 'ASC', 'DESC'. Default 'ASC'. 114 * @type string $domain Limit results to those affiliated with a given domain. Default empty. 115 * @type array $domain__in Array of domains to include affiliated networks for. Default empty. 116 * @type array $domain__not_in Array of domains to exclude affiliated networks for. Default empty. 117 * @type string $path Limit results to those affiliated with a given path. Default empty. 118 * @type array $path__in Array of paths to include affiliated networks for. Default empty. 119 * @type array $path__not_in Array of paths to exclude affiliated networks for. Default empty. 120 * @type string $search Search term(s) to retrieve matching networks for. Default empty. 121 * @type bool $update_network_cache Whether to prime the cache for found networks. Default true. 122 * @type bool $update_network_meta_cache Whether to update the network meta cache. Default true. 122 123 * } 123 124 */ 124 125 public function __construct( $query = '' ) { 125 126 $this->query_var_defaults = array( 126 'network__in' => '', 127 'network__not_in' => '', 128 'count' => false, 129 'fields' => '', 130 'number' => '', 131 'offset' => '', 132 'no_found_rows' => true, 133 'orderby' => 'id', 134 'order' => 'ASC', 135 'domain' => '', 136 'domain__in' => '', 137 'domain__not_in' => '', 138 'path' => '', 139 'path__in' => '', 140 'path__not_in' => '', 141 'search' => '', 142 'update_network_cache' => true, 127 'network__in' => '', 128 'network__not_in' => '', 129 'count' => false, 130 'fields' => '', 131 'number' => '', 132 'offset' => '', 133 'no_found_rows' => true, 134 'orderby' => 'id', 135 'order' => 'ASC', 136 'domain' => '', 137 'domain__in' => '', 138 'domain__not_in' => '', 139 'path' => '', 140 'path__in' => '', 141 'path__not_in' => '', 142 'search' => '', 143 'update_network_cache' => true, 144 'update_network_meta_cache' => true, 143 145 ); 144 146 145 147 if ( ! empty( $query ) ) { … … 248 250 } 249 251 250 252 if ( $this->query_vars['update_network_cache'] ) { 251 _prime_network_caches( $network_ids );253 _prime_network_caches( $network_ids, $this->query_vars['update_network_meta_cache'] ); 252 254 } 253 255 254 256 // Fetch full network objects from the primed cache. -
src/wp-includes/meta.php
34 34 return false; 35 35 } 36 36 37 $object_id = absint( $object_id );37 $object_id = intval( $object_id ); 38 38 if ( ! $object_id ) { 39 39 return false; 40 40 } … … 147 147 return false; 148 148 } 149 149 150 $object_id = absint( $object_id );150 $object_id = intval( $object_id ); 151 151 if ( ! $object_id ) { 152 152 return false; 153 153 } … … 311 311 return false; 312 312 } 313 313 314 $object_id = absint( $object_id );314 $object_id = intval( $object_id ); 315 315 if ( ! $object_id && ! $delete_all ) { 316 316 return false; 317 317 } … … 463 463 return false; 464 464 } 465 465 466 $object_id = absint( $object_id );466 $object_id = intval( $object_id ); 467 467 if ( ! $object_id ) { 468 468 return false; 469 469 } … … 530 530 return false; 531 531 } 532 532 533 $object_id = absint( $object_id );533 $object_id = intval( $object_id ); 534 534 if ( ! $object_id ) { 535 535 return false; 536 536 } -
src/wp-includes/ms-blogs.php
842 842 if ( is_array( $global_groups ) ) { 843 843 wp_cache_add_global_groups( $global_groups ); 844 844 } else { 845 wp_cache_add_global_groups( array( 'users', 'userlogins', 'usermeta', 'user_meta', 'useremail', 'userslugs', 'site-transient', 'site-options', 'blog-lookup', 'blog-details', 'rss', 'global-posts', 'blog-id-cache', 'networks', 'sites', 'site-details' ) );845 wp_cache_add_global_groups( array( 'users', 'userlogins', 'usermeta', 'user_meta', 'useremail', 'userslugs', 'site-transient', 'site-options', 'blog-lookup', 'blog-details', 'rss', 'global-posts', 'blog-id-cache', 'networks', 'sites', 'site-details', 'site_meta' ) ); 846 846 } 847 847 wp_cache_add_non_persistent_groups( array( 'counts', 'plugins' ) ); 848 848 } … … 916 916 if ( is_array( $global_groups ) ) { 917 917 wp_cache_add_global_groups( $global_groups ); 918 918 } else { 919 wp_cache_add_global_groups( array( 'users', 'userlogins', 'usermeta', 'user_meta', 'useremail', 'userslugs', 'site-transient', 'site-options', 'blog-lookup', 'blog-details', 'rss', 'global-posts', 'blog-id-cache', 'networks', 'sites', 'site-details' ) );919 wp_cache_add_global_groups( array( 'users', 'userlogins', 'usermeta', 'user_meta', 'useremail', 'userslugs', 'site-transient', 'site-options', 'blog-lookup', 'blog-details', 'rss', 'global-posts', 'blog-id-cache', 'networks', 'sites', 'site-details', 'site_meta' ) ); 920 920 } 921 921 wp_cache_add_non_persistent_groups( array( 'counts', 'plugins' ) ); 922 922 } … … 1170 1170 1171 1171 foreach ( (array) $ids as $id ) { 1172 1172 wp_cache_delete( $id, 'networks' ); 1173 1173 wp_cache_delete( $id, 'site_meta' ); 1174 1174 /** 1175 1175 * Fires immediately after a network has been removed from the object cache. 1176 1176 * … … 1192 1192 * cache using the network group with the key using the ID of the networks. 1193 1193 * 1194 1194 * @since 4.6.0 1195 * @since 4.8.0 Introduced the `$update_meta_cache` parameter. 1195 1196 * 1196 * @param array $networks Array of network row objects. 1197 * @param array $networks Array of network row objects. 1198 * @param bool $update_meta_cache Optional. Whether to update the meta cache. Default true. 1197 1199 */ 1198 function update_network_cache( $networks ) {1200 function update_network_cache( $networks, $update_meta_cache = true ) { 1199 1201 foreach ( (array) $networks as $network ) { 1200 1202 wp_cache_add( $network->id, $network, 'networks' ); 1201 1203 } 1204 1205 if ( $update_meta_cache ) { 1206 update_networkmeta_cache( wp_list_pluck( $networks, 'id' ) ); 1207 } 1202 1208 } 1203 1209 1204 1210 /** 1205 1211 * Adds any networks from the given IDs to the cache that do not already exist in cache. 1206 1212 * 1207 1213 * @since 4.6.0 1214 * @since 4.8.0 Introduced the `$update_meta_cache` parameter. 1208 1215 * @access private 1209 1216 * 1210 1217 * @see update_network_cache() 1211 1218 * @global wpdb $wpdb WordPress database abstraction object. 1212 1219 * 1213 * @param array $network_ids Array of network IDs. 1220 * @param array $network_ids Array of network IDs. 1221 * @param bool $update_meta_cache Optional. Whether to update the meta cache. Default true. 1214 1222 */ 1215 function _prime_network_caches( $network_ids ) {1223 function _prime_network_caches( $network_ids, $update_meta_cache = true ) { 1216 1224 global $wpdb; 1217 1225 1218 1226 $non_cached_ids = _get_non_cached_ids( $network_ids, 'networks' ); 1219 if ( ! empty( $non_cached_ids ) ) {1220 $fresh_networks = $wpdb->get_results( sprintf( "SELECT $wpdb->site.* FROM $wpdb->siteWHERE id IN (%s)", join( ",", array_map( 'intval', $non_cached_ids ) ) ) );1227 if ( ! empty( $non_cached_ids ) ) { 1228 $fresh_networks = $wpdb->get_results( sprintf( "SELECT * FROM {$wpdb->site} WHERE id IN (%s)", join( ",", array_map( 'intval', $non_cached_ids ) ) ) ); 1221 1229 1222 update_network_cache( $fresh_networks );1230 update_network_cache( $fresh_networks, $update_meta_cache ); 1223 1231 } 1224 1232 } 1225 1233 -
src/wp-includes/ms-functions.php
2517 2517 */ 2518 2518 return apply_filters( 'subdirectory_reserved_names', $names ); 2519 2519 } 2520 2521 /** 2522 * Add metadata to a network. 2523 * 2524 * @since 4.8.0 2525 * 2526 * @param int $id Network ID. 2527 * @param string $meta_key Metadata name. 2528 * @param mixed $meta_value Metadata value. Must be serializable if non-scalar. 2529 * @param bool $unique Optional. Whether the same key should not be added. 2530 * Default false. 2531 * @return int|false Meta ID on success, false on failure. 2532 */ 2533 function add_network_meta( $id, $meta_key, $meta_value, $unique = false ) { 2534 return add_metadata( 'site', $id, $meta_key, $meta_value, $unique ); 2535 } 2536 2537 /** 2538 * Remove from a network, metadata matching key and/or value. 2539 * 2540 * You can match based on the key, or key and value. Removing based on key and 2541 * value, will keep from removing duplicate metadata with the same key. It also 2542 * allows removing all metadata matching key, if needed. 2543 * 2544 * @since 4.8.0 2545 * 2546 * @param int $id Network ID. 2547 * @param string $meta_key Metadata name. 2548 * @param mixed $meta_value Optional. Metadata value. Must be serializable if 2549 * non-scalar. Default empty. 2550 * @return bool True on success, false on failure. 2551 */ 2552 function delete_network_meta( $id, $meta_key, $meta_value = '' ) { 2553 return delete_metadata( 'site', $id, $meta_key, $meta_value ); 2554 } 2555 2556 /** 2557 * Retrieve from a network, metadata value by key. 2558 * 2559 * @since 4.8.0 2560 * 2561 * @param int $id Network ID. 2562 * @param string $meta_key Optional. The meta key to retrieve. By default, returns 2563 * data for all keys. Default empty. 2564 * @param bool $single Optional. Whether to return a single value. Default false. 2565 * @return mixed Will be an array if $single is false. Will be value of meta data 2566 * field if $single is true. 2567 */ 2568 function get_network_meta( $id, $meta_key = '', $single = false ) { 2569 return get_metadata( 'site', $id, $meta_key, $single ); 2570 } 2571 2572 /** 2573 * Update metadata for a network ID, and/or key, and/or value. 2574 * 2575 * Use the $prev_value parameter to differentiate between meta fields with the 2576 * same key and network ID. 2577 * 2578 * If the meta field for the network does not exist, it will be added. 2579 * 2580 * @since 4.8.0 2581 * 2582 * @param int $id Network ID. 2583 * @param string $meta_key Metadata key. 2584 * @param mixed $meta_value Metadata value. Must be serializable if non-scalar. 2585 * @param mixed $prev_value Optional. Previous value to check before removing. 2586 * Default empty. 2587 * @return int|bool Meta ID if the key didn't exist, true on successful update, 2588 * false on failure. 2589 */ 2590 function update_network_meta( $id, $meta_key, $meta_value, $prev_value = '' ) { 2591 return update_metadata( 'site', $id, $meta_key, $meta_value, $prev_value ); 2592 } 2593 2594 /** 2595 * Delete everything from network meta matching meta key. 2596 * 2597 * @since 4.8.0 2598 * 2599 * @param string $network_meta_key Key to search for when deleting. 2600 * 2601 * @return bool Whether the network meta key was deleted from the database. 2602 */ 2603 function delete_network_meta_by_key( $network_meta_key ) { 2604 return delete_metadata( 'site', null, $network_meta_key, '', true ); 2605 } 2606 2607 /** 2608 * Updates metadata cache for list of network IDs. 2609 * 2610 * Performs SQL query to retrieve the metadata for the network IDs and updates the 2611 * metadata cache for the posts. Therefore, the functions, which call this 2612 * function, do not need to perform SQL queries on their own. 2613 * 2614 * @since 4.8.0 2615 * 2616 * @param array $network_ids List of network IDs. 2617 * @return array|false Returns false if there is nothing to update or an array 2618 * of metadata. 2619 */ 2620 function update_networkmeta_cache( $network_ids) { 2621 return update_meta_cache( 'site', $network_ids ); 2622 } -
src/wp-includes/option.php
205 205 * 206 206 * @since 3.0.0 207 207 * 208 * @ global wpdb $wpdb WordPress database abstraction object.208 * @see update_networkmeta_cache() 209 209 * 210 * @param int $ site_id Optional siteID for which to query the options. Defaults to the current site.210 * @param int $network_id Optional network ID for which to query the options. Defaults to the current site. 211 211 */ 212 function wp_load_core_site_options( $site_id = null ) { 213 global $wpdb; 212 function wp_load_core_site_options( $network_id = null ) { 214 213 215 if ( ! is_multisite() || wp_using_ext_object_cache() || wp_installing() ) 214 if ( ! is_multisite() || wp_using_ext_object_cache() || wp_installing() ) { 216 215 return; 216 } 217 217 218 if ( empty($site_id) ) 219 $site_id = $wpdb->siteid; 220 221 $core_options = array('site_name', 'siteurl', 'active_sitewide_plugins', '_site_transient_timeout_theme_roots', '_site_transient_theme_roots', 'site_admins', 'can_compress_scripts', 'global_terms_enabled', 'ms_files_rewriting' ); 222 223 $core_options_in = "'" . implode("', '", $core_options) . "'"; 224 $options = $wpdb->get_results( $wpdb->prepare("SELECT meta_key, meta_value FROM $wpdb->sitemeta WHERE meta_key IN ($core_options_in) AND site_id = %d", $site_id) ); 225 226 foreach ( $options as $option ) { 227 $key = $option->meta_key; 228 $cache_key = "{$site_id}:$key"; 229 $option->meta_value = maybe_unserialize( $option->meta_value ); 218 $network_id = (int) $network_id; 230 219 231 wp_cache_set( $cache_key, $option->meta_value, 'site-options' ); 220 // Fallback to the current network if a network ID is not specified. 221 if ( empty( $network_id ) ) { 222 $network_id = get_current_network_id(); 232 223 } 224 225 update_networkmeta_cache( $network_id ); 233 226 } 234 227 235 228 /** … … 1080 1073 * Retrieve a network's option value based on the option name. 1081 1074 * 1082 1075 * @since 4.4.0 1076 * @since 4.8.0 Modified into wrapper for get_network_meta() 1083 1077 * 1084 1078 * @see get_option() 1079 * @see get_network_meta() 1085 1080 * 1086 1081 * @global wpdb $wpdb 1087 1082 * … … 1091 1086 * @return mixed Value set for the option. 1092 1087 */ 1093 1088 function get_network_option( $network_id, $option, $default = false ) { 1094 global $wpdb;1095 1089 1096 1090 if ( $network_id && ! is_numeric( $network_id ) ) { 1097 1091 return false; … … 1127 1121 return $pre; 1128 1122 } 1129 1123 1130 // prevent non-existent options from triggering multiple queries 1131 $notoptions_key = "$network_id:notoptions"; 1132 $notoptions = wp_cache_get( $notoptions_key, 'site-options' ); 1133 1134 if ( isset( $notoptions[ $option ] ) ) { 1135 1136 /** 1137 * Filters a specific default network option. 1138 * 1139 * The dynamic portion of the hook name, `$option`, refers to the option name. 1140 * 1141 * @since 3.4.0 1142 * @since 4.4.0 The `$option` parameter was added. 1143 * @since 4.7.0 The `$network_id` parameter was added. 1144 * 1145 * @param mixed $default The value to return if the site option does not exist 1146 * in the database. 1147 * @param string $option Option name. 1148 * @param int $network_id ID of the network. 1149 */ 1150 return apply_filters( "default_site_option_{$option}", $default, $option, $network_id ); 1151 } 1124 /** 1125 * Filters a specific default network option. 1126 * 1127 * The dynamic portion of the hook name, `$option`, refers to the option name. 1128 * 1129 * @since 3.4.0 1130 * @since 4.4.0 The `$option` parameter was added. 1131 * @since 4.7.0 The `$network_id` parameter was added. 1132 * 1133 * @param mixed $default The value to return if the site option does not exist 1134 * in the database. 1135 * @param string $option Option name. 1136 * @param int $network_id ID of the network. 1137 */ 1138 $default = apply_filters( 'default_site_option_' . $option, $default, $option, $network_id ); 1152 1139 1153 1140 if ( ! is_multisite() ) { 1154 /** This filter is documented in wp-includes/option.php */1155 $default = apply_filters( 'default_site_option_' . $option, $default, $option, $network_id );1156 1141 $value = get_option( $option, $default ); 1157 1142 } else { 1158 $cache_key = "$network_id:$option"; 1159 $value = wp_cache_get( $cache_key, 'site-options' ); 1160 1161 if ( ! isset( $value ) || false === $value ) { 1162 $row = $wpdb->get_row( $wpdb->prepare( "SELECT meta_value FROM $wpdb->sitemeta WHERE meta_key = %s AND site_id = %d", $option, $network_id ) ); 1163 1164 // Has to be get_row instead of get_var because of funkiness with 0, false, null values 1165 if ( is_object( $row ) ) { 1166 $value = $row->meta_value; 1167 $value = maybe_unserialize( $value ); 1168 wp_cache_set( $cache_key, $value, 'site-options' ); 1169 } else { 1170 if ( ! is_array( $notoptions ) ) { 1171 $notoptions = array(); 1172 } 1173 $notoptions[ $option ] = true; 1174 wp_cache_set( $notoptions_key, $notoptions, 'site-options' ); 1175 1176 /** This filter is documented in wp-includes/option.php */ 1177 $value = apply_filters( 'default_site_option_' . $option, $default, $option, $network_id ); 1178 } 1143 $meta = get_network_meta( $network_id, $option ); 1144 if ( is_array( $meta ) && ! empty( $meta ) ) { 1145 $value = array_shift( $meta ); 1146 } else { 1147 $value = $default; 1179 1148 } 1180 1149 } 1181 1150 … … 1202 1171 * Existing options will not be updated. 1203 1172 * 1204 1173 * @since 4.4.0 1174 * @since 4.8.0 Modified into wrapper for add_network_meta() 1205 1175 * 1206 1176 * @see add_option() 1177 * @see add_network_meta() 1207 1178 * 1208 1179 * @global wpdb $wpdb 1209 1180 * … … 1213 1184 * @return bool False if option was not added and true if option was added. 1214 1185 */ 1215 1186 function add_network_option( $network_id, $option, $value ) { 1216 global $wpdb;1217 1187 1218 1188 if ( $network_id && ! is_numeric( $network_id ) ) { 1219 1189 return false; … … 1244 1214 */ 1245 1215 $value = apply_filters( "pre_add_site_option_{$option}", $value, $option, $network_id ); 1246 1216 1247 $notoptions_key = "$network_id:notoptions";1248 1249 1217 if ( ! is_multisite() ) { 1250 1218 $result = add_option( $option, $value, '', 'no' ); 1251 1219 } else { 1252 $cache_key = "$network_id:$option"; 1253 1254 // Make sure the option doesn't already exist. We can check the 'notoptions' cache before we ask for a db query 1255 $notoptions = wp_cache_get( $notoptions_key, 'site-options' ); 1256 if ( ! is_array( $notoptions ) || ! isset( $notoptions[ $option ] ) ) { 1257 if ( false !== get_network_option( $network_id, $option, false ) ) { 1258 return false; 1259 } 1260 } 1261 1262 $value = sanitize_option( $option, $value ); 1263 1264 $serialized_value = maybe_serialize( $value ); 1265 $result = $wpdb->insert( $wpdb->sitemeta, array( 'site_id' => $network_id, 'meta_key' => $option, 'meta_value' => $serialized_value ) ); 1266 1267 if ( ! $result ) { 1268 return false; 1269 } 1270 1271 wp_cache_set( $cache_key, $value, 'site-options' ); 1272 1273 // This option exists now 1274 $notoptions = wp_cache_get( $notoptions_key, 'site-options' ); // yes, again... we need it to be fresh 1275 if ( is_array( $notoptions ) && isset( $notoptions[ $option ] ) ) { 1276 unset( $notoptions[ $option ] ); 1277 wp_cache_set( $notoptions_key, $notoptions, 'site-options' ); 1278 } 1220 $value = sanitize_option( $option, $value ); 1221 $result = add_network_meta( $network_id, $option, $value, true ); 1279 1222 } 1280 1223 1281 1224 if ( $result ) { … … 1317 1260 * Removes a network option by name. 1318 1261 * 1319 1262 * @since 4.4.0 1263 * @since 4.8.0 Modified into wrapper for delete_network_meta() 1320 1264 * 1321 1265 * @see delete_option() 1266 * @see delete_network_meta() 1322 1267 * 1323 1268 * @global wpdb $wpdb 1324 1269 * … … 1327 1272 * @return bool True, if succeed. False, if failure. 1328 1273 */ 1329 1274 function delete_network_option( $network_id, $option ) { 1330 global $wpdb;1331 1275 1332 1276 if ( $network_id && ! is_numeric( $network_id ) ) { 1333 1277 return false; … … 1357 1301 if ( ! is_multisite() ) { 1358 1302 $result = delete_option( $option ); 1359 1303 } else { 1360 $row = $wpdb->get_row( $wpdb->prepare( "SELECT meta_id FROM {$wpdb->sitemeta} WHERE meta_key = %s AND site_id = %d", $option, $network_id ) ); 1361 if ( is_null( $row ) || ! $row->meta_id ) { 1362 return false; 1363 } 1364 $cache_key = "$network_id:$option"; 1365 wp_cache_delete( $cache_key, 'site-options' ); 1366 1367 $result = $wpdb->delete( $wpdb->sitemeta, array( 'meta_key' => $option, 'site_id' => $network_id ) ); 1304 $result = delete_network_meta( $network_id, $option ); 1368 1305 } 1369 1306 1370 1307 if ( $result ) { … … 1404 1341 * Update the value of a network option that was already added. 1405 1342 * 1406 1343 * @since 4.4.0 1344 * @since 4.8.0 Modified into wrapper for update_network_meta() 1407 1345 * 1408 1346 * @see update_option() 1347 * @see update_network_meta() 1409 1348 * 1410 1349 * @global wpdb $wpdb 1411 1350 * … … 1415 1354 * @return bool False if value was not updated and true if value was updated. 1416 1355 */ 1417 1356 function update_network_option( $network_id, $option, $value ) { 1418 global $wpdb;1419 1357 1420 1358 if ( $network_id && ! is_numeric( $network_id ) ) { 1421 1359 return false; … … 1449 1387 */ 1450 1388 $value = apply_filters( "pre_update_site_option_{$option}", $value, $old_value, $option, $network_id ); 1451 1389 1452 if ( $value === $old_value ) {1453 return false;1454 }1455 1456 1390 if ( false === $old_value ) { 1457 1391 return add_network_option( $network_id, $option, $value ); 1458 1392 } 1459 1393 1460 $notoptions_key = "$network_id:notoptions";1461 $notoptions = wp_cache_get( $notoptions_key, 'site-options' );1462 if ( is_array( $notoptions ) && isset( $notoptions[ $option ] ) ) {1463 unset( $notoptions[ $option ] );1464 wp_cache_set( $notoptions_key, $notoptions, 'site-options' );1465 }1466 1467 1394 if ( ! is_multisite() ) { 1468 1395 $result = update_option( $option, $value, 'no' ); 1469 1396 } else { 1470 $value = sanitize_option( $option, $value ); 1471 1472 $serialized_value = maybe_serialize( $value ); 1473 $result = $wpdb->update( $wpdb->sitemeta, array( 'meta_value' => $serialized_value ), array( 'site_id' => $network_id, 'meta_key' => $option ) ); 1474 1475 if ( $result ) { 1476 $cache_key = "$network_id:$option"; 1477 wp_cache_set( $cache_key, $value, 'site-options' ); 1478 } 1397 $value = sanitize_option( $option, $value ); 1398 $result = update_network_meta( $network_id, $option, $value, $old_value ); 1479 1399 } 1480 1400 1481 1401 if ( $result ) { -
src/wp-settings.php
94 94 95 95 // Load early WordPress files. 96 96 require( ABSPATH . WPINC . '/compat.php' ); 97 require( ABSPATH . WPINC . '/class-wp-list-util.php' );98 97 require( ABSPATH . WPINC . '/functions.php' ); 98 require( ABSPATH . WPINC . '/formatting.php' ); 99 require( ABSPATH . WPINC . '/meta.php' ); 100 require( ABSPATH . WPINC . '/class-wp-list-util.php' ); 99 101 require( ABSPATH . WPINC . '/class-wp-matchesmapregex.php' ); 100 102 require( ABSPATH . WPINC . '/class-wp.php' ); 101 103 require( ABSPATH . WPINC . '/class-wp-error.php' ); … … 119 121 if ( is_multisite() ) { 120 122 require( ABSPATH . WPINC . '/class-wp-site-query.php' ); 121 123 require( ABSPATH . WPINC . '/class-wp-network-query.php' ); 124 require( ABSPATH . WPINC . '/ms-functions.php' ); 122 125 require( ABSPATH . WPINC . '/ms-blogs.php' ); 123 126 require( ABSPATH . WPINC . '/ms-settings.php' ); 124 127 } elseif ( ! defined( 'MULTISITE' ) ) { … … 142 145 // Load most of WordPress. 143 146 require( ABSPATH . WPINC . '/class-wp-walker.php' ); 144 147 require( ABSPATH . WPINC . '/class-wp-ajax-response.php' ); 145 require( ABSPATH . WPINC . '/formatting.php' );146 148 require( ABSPATH . WPINC . '/capabilities.php' ); 147 149 require( ABSPATH . WPINC . '/class-wp-roles.php' ); 148 150 require( ABSPATH . WPINC . '/class-wp-role.php' ); … … 157 159 require( ABSPATH . WPINC . '/class-wp-user-query.php' ); 158 160 require( ABSPATH . WPINC . '/class-wp-session-tokens.php' ); 159 161 require( ABSPATH . WPINC . '/class-wp-user-meta-session-tokens.php' ); 160 require( ABSPATH . WPINC . '/meta.php' );161 162 require( ABSPATH . WPINC . '/class-wp-meta-query.php' ); 162 163 require( ABSPATH . WPINC . '/class-wp-metadata-lazyloader.php' ); 163 164 require( ABSPATH . WPINC . '/general-template.php' ); … … 244 245 245 246 // Load multisite-specific files. 246 247 if ( is_multisite() ) { 247 require( ABSPATH . WPINC . '/ms-functions.php' );248 248 require( ABSPATH . WPINC . '/ms-default-filters.php' ); 249 249 require( ABSPATH . WPINC . '/ms-deprecated.php' ); 250 250 } -
tests/phpunit/includes/testcase.php
301 301 $wp_object_cache->__remoteset(); 302 302 } 303 303 wp_cache_flush(); 304 wp_cache_add_global_groups( array( 'users', 'userlogins', 'usermeta', 'user_meta', 'useremail', 'userslugs', 'site-transient', 'site-options', 'blog-lookup', 'blog-details', 'rss', 'global-posts', 'blog-id-cache', 'networks', 'sites', 'site-details' ) );304 wp_cache_add_global_groups( array( 'users', 'userlogins', 'usermeta', 'user_meta', 'useremail', 'userslugs', 'site-transient', 'site-options', 'blog-lookup', 'blog-details', 'rss', 'global-posts', 'blog-id-cache', 'networks', 'sites', 'site-details', 'site_meta' ) ); 305 305 wp_cache_add_non_persistent_groups( array( 'comment', 'counts', 'plugins' ) ); 306 306 } 307 307 -
tests/phpunit/tests/cache.php
22 22 global $wp_object_cache; 23 23 $cache_class = get_class( $wp_object_cache ); 24 24 $cache = new $cache_class(); 25 $cache->add_global_groups( array( 'global-cache-test', 'users', 'userlogins', 'usermeta', 'user_meta', 'useremail', 'userslugs', 'site-transient', 'site-options', 'blog-lookup', 'blog-details', 'rss', 'global-posts', 'blog-id-cache', 'networks', 'sites', 'site-details' ) );25 $cache->add_global_groups( array( 'global-cache-test', 'users', 'userlogins', 'usermeta', 'user_meta', 'useremail', 'userslugs', 'site-transient', 'site-options', 'blog-lookup', 'blog-details', 'rss', 'global-posts', 'blog-id-cache', 'networks', 'sites', 'site-details', 'site_meta' ) ); 26 26 return $cache; 27 27 } 28 28 -
tests/phpunit/tests/multisite/network.php
202 202 203 203 $site_count = get_blog_count( self::$different_network_id ); 204 204 205 $this->assert Same( count( self::$different_site_ids ), $site_count );205 $this->assertEquals( count( self::$different_site_ids ), $site_count ); 206 206 } 207 207 208 208 /** -
tests/phpunit/tests/option/multisite.php
144 144 //$this->assertFalse( get_option( $key2 ) ); // check get_option() 145 145 } 146 146 147 /**148 * @group multisite149 */150 function test_site_notoptions() {151 global $wpdb;152 $notoptions_key = "{$wpdb->siteid}:notoptions";153 154 $_notoptions = wp_cache_get( 'notoptions', 'site-options' );155 $this->assertEmpty( $_notoptions );156 $_notoptions1 = wp_cache_get( $notoptions_key, 'site-options' );157 $this->assertEmpty( $_notoptions1 );158 159 get_site_option( 'burrito' );160 161 $notoptions = wp_cache_get( 'notoptions', 'site-options' );162 $this->assertEmpty( $notoptions );163 $notoptions1 = wp_cache_get( $notoptions_key, 'site-options' );164 $this->assertNotEmpty( $notoptions1 );165 }166 147 167 148 function test_users_can_register_signup_filter() { 168 149