<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[54080] trunk: Networks and Sites: Use metadata api in ``*_network_options` functions.</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { white-space: pre-line; overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="https://core.trac.wordpress.org/changeset/54080">54080</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"https://core.trac.wordpress.org/changeset/54080","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>spacedmonkey</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2022-09-06 11:26:45 +0000 (Tue, 06 Sep 2022)</dd>
</dl>
<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>Networks and Sites: Use metadata api in ``*_network_options` functions.
Replace logic found in `get_network_option`, `update_network_option` and `delete_network_option` to use the metadata api. Using the metadata api has a number of benefits, such as consistency, default values and useful filters. This change also improves performance by priming the caches of all network options in a single database request.
Props spacedmonkey, swissspidy, sc0ttkclark, johnjamesjacoby, flixos90, jeremyfelt, pento, peterwilsoncc, mukesh27, desrosj.
Fixes <a href="https://core.trac.wordpress.org/ticket/37181">#37181</a></pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpincludesclasswpnetworkqueryphp">trunk/src/wp-includes/class-wp-network-query.php</a></li>
<li><a href="#trunksrcwpincludesloadphp">trunk/src/wp-includes/load.php</a></li>
<li><a href="#trunksrcwpincludesmsblogsphp">trunk/src/wp-includes/ms-blogs.php</a></li>
<li><a href="#trunksrcwpincludesmsfunctionsphp">trunk/src/wp-includes/ms-functions.php</a></li>
<li><a href="#trunksrcwpincludesmsnetworkphp">trunk/src/wp-includes/ms-network.php</a></li>
<li><a href="#trunksrcwpincludesoptionphp">trunk/src/wp-includes/option.php</a></li>
<li><a href="#trunktestsphpunittestsajaxCompressionphp">trunk/tests/phpunit/tests/ajax/Compression.php</a></li>
<li><a href="#trunktestsphpunittestsoptionmultisitephp">trunk/tests/phpunit/tests/option/multisite.php</a></li>
<li><a href="#trunktestsphpunittestsoptionnetworkOptionphp">trunk/tests/phpunit/tests/option/networkOption.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpincludesclasswpnetworkqueryphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/class-wp-network-query.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/class-wp-network-query.php 2022-09-06 02:50:35 UTC (rev 54079)
+++ trunk/src/wp-includes/class-wp-network-query.php 2022-09-06 11:26:45 UTC (rev 54080)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -89,49 +89,52 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string|array $query {
</span><span class="cx" style="display: block; padding: 0 10px"> * Optional. Array or query string of network query parameters. Default empty.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @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.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @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.
</ins><span class="cx" style="display: block; padding: 0 10px"> * }
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function __construct( $query = '' ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $this->query_var_defaults = array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- '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,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ '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,
</ins><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! empty( $query ) ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -242,8 +245,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> // $args can include anything. Only use the args defined in the query_var_defaults to compute the key.
</span><span class="cx" style="display: block; padding: 0 10px"> $_args = wp_array_slice_assoc( $this->query_vars, array_keys( $this->query_var_defaults ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Ignore the $fields, $update_network_cache arguments as the queried result will be the same regardless.
- unset( $_args['fields'], $_args['update_network_cache'] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Ignore the $fields, $update_network_cache, and $update_network_meta_cache arguments as the queried result will be the same regardless.
+ unset( $_args['fields'], $_args['update_network_cache'], $_args['update_network_meta_cache'] );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $key = md5( serialize( $_args ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $last_changed = wp_cache_get_last_changed( 'networks' );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -285,7 +288,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $this->query_vars['update_network_cache'] ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- _prime_network_caches( $network_ids );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ _prime_network_caches( $network_ids, $this->query_vars['update_network_meta_cache'] );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Fetch full network objects from the primed cache.
</span></span></pre></div>
<a id="trunksrcwpincludesloadphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/load.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/load.php 2022-09-06 02:50:35 UTC (rev 54079)
+++ trunk/src/wp-includes/load.php 2022-09-06 11:26:45 UTC (rev 54080)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -743,6 +743,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'site-details',
</span><span class="cx" style="display: block; padding: 0 10px"> 'site-options',
</span><span class="cx" style="display: block; padding: 0 10px"> 'site-transient',
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'site_meta',
</ins><span class="cx" style="display: block; padding: 0 10px"> 'rss',
</span><span class="cx" style="display: block; padding: 0 10px"> 'users',
</span><span class="cx" style="display: block; padding: 0 10px"> 'useremail',
</span></span></pre></div>
<a id="trunksrcwpincludesmsblogsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/ms-blogs.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/ms-blogs.php 2022-09-06 02:50:35 UTC (rev 54079)
+++ trunk/src/wp-includes/ms-blogs.php 2022-09-06 11:26:45 UTC (rev 54080)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -564,6 +564,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'site-details',
</span><span class="cx" style="display: block; padding: 0 10px"> 'site-options',
</span><span class="cx" style="display: block; padding: 0 10px"> 'site-transient',
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'site_meta',
</ins><span class="cx" style="display: block; padding: 0 10px"> 'rss',
</span><span class="cx" style="display: block; padding: 0 10px"> 'users',
</span><span class="cx" style="display: block; padding: 0 10px"> 'useremail',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -655,6 +656,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'site-details',
</span><span class="cx" style="display: block; padding: 0 10px"> 'site-options',
</span><span class="cx" style="display: block; padding: 0 10px"> 'site-transient',
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'site_meta',
</ins><span class="cx" style="display: block; padding: 0 10px"> 'rss',
</span><span class="cx" style="display: block; padding: 0 10px"> 'users',
</span><span class="cx" style="display: block; padding: 0 10px"> 'useremail',
</span></span></pre></div>
<a id="trunksrcwpincludesmsfunctionsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/ms-functions.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/ms-functions.php 2022-09-06 02:50:35 UTC (rev 54079)
+++ trunk/src/wp-includes/ms-functions.php 2022-09-06 11:26:45 UTC (rev 54080)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -113,7 +113,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @return int Number of active sites on the network.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function get_blog_count( $network_id = null ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- return get_network_option( $network_id, 'blog_count' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ return (int) get_network_option( $network_id, 'blog_count' );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2654,7 +2654,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @param int $space_allowed Upload quota in megabytes for the current blog.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- return apply_filters( 'get_space_allowed', $space_allowed );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ return (int) apply_filters( 'get_space_allowed', $space_allowed );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span></span></pre></div>
<a id="trunksrcwpincludesmsnetworkphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/ms-network.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/ms-network.php 2022-09-06 02:50:35 UTC (rev 54079)
+++ trunk/src/wp-includes/ms-network.php 2022-09-06 11:26:45 UTC (rev 54080)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -84,6 +84,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $network_ids = (array) $ids;
</span><span class="cx" style="display: block; padding: 0 10px"> wp_cache_delete_multiple( $network_ids, 'networks' );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_cache_delete_multiple( $network_ids, 'site_meta' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> foreach ( $network_ids as $id ) {
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -107,15 +108,22 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * cache using the network group with the key using the ID of the networks.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 4.6.0
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 6.1.0 Introduced the `$update_meta_cache` parameter.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param array $networks Array of network row objects.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param array $networks Array of network row objects.
+ * @param bool $update_meta_cache Whether to update site meta cache. Default true.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-function update_network_cache( $networks ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+function update_network_cache( $networks, $update_meta_cache = true ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $data = array();
</span><span class="cx" style="display: block; padding: 0 10px"> foreach ( (array) $networks as $network ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $data[ $network->id ] = $network;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> wp_cache_add_multiple( $data, 'networks' );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( $update_meta_cache ) {
+ $network_ids = array_keys( $data );
+ update_meta_cache( 'site', $network_ids );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -122,14 +130,16 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * Adds any networks from the given IDs to the cache that do not already exist in cache.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 4.6.0
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 6.1.0 Introduced the `$update_meta_cache` parameter.
</ins><span class="cx" style="display: block; padding: 0 10px"> * @since 6.1.0 This function is no longer marked as "private".
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @see update_network_cache()
</span><span class="cx" style="display: block; padding: 0 10px"> * @global wpdb $wpdb WordPress database abstraction object.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param array $network_ids Array of network IDs.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param array $network_ids Array of network IDs.
+ * @param bool $update_meta_cache Whether to update site meta cache. Default true.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-function _prime_network_caches( $network_ids ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+function _prime_network_caches( $network_ids, $update_meta_cache = true ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> global $wpdb;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $non_cached_ids = _get_non_cached_ids( $network_ids, 'networks' );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -136,6 +146,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! empty( $non_cached_ids ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $fresh_networks = $wpdb->get_results( sprintf( "SELECT $wpdb->site.* FROM $wpdb->site WHERE id IN (%s)", implode( ',', array_map( 'intval', $non_cached_ids ) ) ) ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- update_network_cache( $fresh_networks );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ update_network_cache( $fresh_networks, $update_meta_cache );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre></div>
<a id="trunksrcwpincludesoptionphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/option.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/option.php 2022-09-06 02:50:35 UTC (rev 54079)
+++ trunk/src/wp-includes/option.php 2022-09-06 11:26:45 UTC (rev 54080)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -324,15 +324,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * Loads and caches certain often requested site options if is_multisite() and a persistent cache is not being used.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 3.0.0
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 6.1.0 Uses update_meta_cache
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @global wpdb $wpdb WordPress database abstraction object.
- *
</del><span class="cx" style="display: block; padding: 0 10px"> * @param int $network_id Optional site ID for which to query the options. Defaults to the current site.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function wp_load_core_site_options( $network_id = null ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
-
- if ( ! is_multisite() || wp_using_ext_object_cache() || wp_installing() ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( ! is_multisite() || wp_installing() ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> return;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -340,20 +337,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $network_id = get_current_network_id();
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $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' );
-
- $core_options_in = "'" . implode( "', '", $core_options ) . "'";
- $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", $network_id ) );
-
- $data = array();
- foreach ( $options as $option ) {
- $key = $option->meta_key;
- $cache_key = "{$network_id}:$key";
- $option->meta_value = maybe_unserialize( $option->meta_value );
-
- $data[ $cache_key ] = $option->meta_value;
- }
- wp_cache_set_multiple( $data, 'site-options' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ update_meta_cache( 'site', $network_id );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1362,11 +1346,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * Retrieves a network's option value based on the option name.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 4.4.0
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 6.1.0 Now uses get_metadata().
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @see get_option()
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @see get_metadata()
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @global wpdb $wpdb WordPress database abstraction object.
- *
</del><span class="cx" style="display: block; padding: 0 10px"> * @param int $network_id ID of the network. Can be null to default to the current network ID.
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $option Name of the option to retrieve. Expected to not be SQL-escaped.
</span><span class="cx" style="display: block; padding: 0 10px"> * @param mixed $default Optional. Value to return if the option doesn't exist. Default false.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1373,8 +1357,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @return mixed Value set for the option.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function get_network_option( $network_id, $option, $default = false ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
-
</del><span class="cx" style="display: block; padding: 0 10px"> if ( $network_id && ! is_numeric( $network_id ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return false;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1415,12 +1397,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> return $pre;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Prevent non-existent options from triggering multiple queries.
- $notoptions_key = "$network_id:notoptions";
- $notoptions = wp_cache_get( $notoptions_key, 'site-options' );
-
- if ( is_array( $notoptions ) && isset( $notoptions[ $option ] ) ) {
-
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( ! is_multisite() ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Filters the value of a specific default network option.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1435,44 +1412,21 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $option Option name.
</span><span class="cx" style="display: block; padding: 0 10px"> * @param int $network_id ID of the network.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- return apply_filters( "default_site_option_{$option}", $default, $option, $network_id );
- }
-
- if ( ! is_multisite() ) {
- /** This filter is documented in wp-includes/option.php */
- $default = apply_filters( 'default_site_option_' . $option, $default, $option, $network_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $default = apply_filters( "default_site_option_{$option}", $default, $option, $network_id );
</ins><span class="cx" style="display: block; padding: 0 10px"> $value = get_option( $option, $default );
</span><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $cache_key = "$network_id:$option";
- $value = wp_cache_get( $cache_key, 'site-options' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $meta = get_metadata_raw( 'site', $network_id, $option );
+ if ( is_array( $meta ) && ! empty( $meta ) ) {
+ $value = array_shift( $meta );
+ } else {
+ /** This filter is documented in wp-includes/option.php */
+ $value = apply_filters( "default_site_option_{$option}", $default, $option, $network_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( ! isset( $value ) || false === $value ) {
- $row = $wpdb->get_row( $wpdb->prepare( "SELECT meta_value FROM $wpdb->sitemeta WHERE meta_key = %s AND site_id = %d", $option, $network_id ) );
-
- // Has to be get_row() instead of get_var() because of funkiness with 0, false, null values.
- if ( is_object( $row ) ) {
- $value = $row->meta_value;
- $value = maybe_unserialize( $value );
- wp_cache_set( $cache_key, $value, 'site-options' );
- } else {
- if ( ! is_array( $notoptions ) ) {
- $notoptions = array();
- }
-
- $notoptions[ $option ] = true;
- wp_cache_set( $notoptions_key, $notoptions, 'site-options' );
-
- /** This filter is documented in wp-includes/option.php */
- $value = apply_filters( 'default_site_option_' . $option, $default, $option, $network_id );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /** This action is documented in wp-includes/meta.php */
+ $value = apply_filters( 'default_site_metadata', $value, $network_id, $option, true, 'site' );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( ! is_array( $notoptions ) ) {
- $notoptions = array();
- wp_cache_set( $notoptions_key, $notoptions, 'site-options' );
- }
-
</del><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Filters the value of an existing network option.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1496,11 +1450,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * Existing options will not be updated.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 4.4.0
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 6.1.0 Now uses add_metadata().
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @see add_option()
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @see add_metadata()
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @global wpdb $wpdb WordPress database abstraction object.
- *
</del><span class="cx" style="display: block; padding: 0 10px"> * @param int $network_id ID of the network. Can be null to default to the current network ID.
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $option Name of the option to add. Expected to not be SQL-escaped.
</span><span class="cx" style="display: block; padding: 0 10px"> * @param mixed $value Option value, can be anything. Expected to not be SQL-escaped.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1507,8 +1461,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @return bool True if the option was added, false otherwise.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function add_network_option( $network_id, $option, $value ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
-
</del><span class="cx" style="display: block; padding: 0 10px"> if ( $network_id && ! is_numeric( $network_id ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return false;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1538,48 +1490,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> $value = apply_filters( "pre_add_site_option_{$option}", $value, $option, $network_id );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $notoptions_key = "$network_id:notoptions";
-
</del><span class="cx" style="display: block; padding: 0 10px"> if ( ! is_multisite() ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $result = add_option( $option, $value, '', 'no' );
</span><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $cache_key = "$network_id:$option";
-
- // Make sure the option doesn't already exist.
- // We can check the 'notoptions' cache before we ask for a DB query.
- $notoptions = wp_cache_get( $notoptions_key, 'site-options' );
-
- if ( ! is_array( $notoptions ) || ! isset( $notoptions[ $option ] ) ) {
- if ( false !== get_network_option( $network_id, $option, false ) ) {
- return false;
- }
- }
-
- $value = sanitize_option( $option, $value );
-
- $serialized_value = maybe_serialize( $value );
- $result = $wpdb->insert(
- $wpdb->sitemeta,
- array(
- 'site_id' => $network_id,
- 'meta_key' => $option,
- 'meta_value' => $serialized_value,
- )
- );
-
- if ( ! $result ) {
- return false;
- }
-
- wp_cache_set( $cache_key, $value, 'site-options' );
-
- // This option exists now.
- $notoptions = wp_cache_get( $notoptions_key, 'site-options' ); // Yes, again... we need it to be fresh.
-
- if ( is_array( $notoptions ) && isset( $notoptions[ $option ] ) ) {
- unset( $notoptions[ $option ] );
- wp_cache_set( $notoptions_key, $notoptions, 'site-options' );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $value = sanitize_option( $option, $value );
+ $result = add_metadata( 'site', $network_id, wp_slash( $option ), wp_slash( $value ), true );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $result ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1621,8 +1536,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * Removes a network option by name.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 4.4.0
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 6.1.0 Now uses delete_metadata().
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @see delete_option()
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @see delete_metadata()
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @global wpdb $wpdb WordPress database abstraction object.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1631,8 +1548,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @return bool True if the option was deleted, false otherwise.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function delete_network_option( $network_id, $option ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
-
</del><span class="cx" style="display: block; padding: 0 10px"> if ( $network_id && ! is_numeric( $network_id ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return false;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1661,20 +1576,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! is_multisite() ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $result = delete_option( $option );
</span><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $row = $wpdb->get_row( $wpdb->prepare( "SELECT meta_id FROM {$wpdb->sitemeta} WHERE meta_key = %s AND site_id = %d", $option, $network_id ) );
- if ( is_null( $row ) || ! $row->meta_id ) {
- return false;
- }
- $cache_key = "$network_id:$option";
- wp_cache_delete( $cache_key, 'site-options' );
-
- $result = $wpdb->delete(
- $wpdb->sitemeta,
- array(
- 'meta_key' => $option,
- 'site_id' => $network_id,
- )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $result = delete_metadata( 'site', $network_id, wp_slash( $option ), '' );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $result ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1714,11 +1616,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * Updates the value of a network option that was already added.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 4.4.0
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 6.1.0 Now uses update_metadata().
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @see update_option()
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @see update_metadata()
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @global wpdb $wpdb WordPress database abstraction object.
- *
</del><span class="cx" style="display: block; padding: 0 10px"> * @param int $network_id ID of the network. Can be null to default to the current network ID.
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $option Name of the option. Expected to not be SQL-escaped.
</span><span class="cx" style="display: block; padding: 0 10px"> * @param mixed $value Option value. Expected to not be SQL-escaped.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1725,8 +1627,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @return bool True if the value was updated, false otherwise.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function update_network_option( $network_id, $option, $value ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
-
</del><span class="cx" style="display: block; padding: 0 10px"> if ( $network_id && ! is_numeric( $network_id ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return false;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1776,33 +1676,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> return add_network_option( $network_id, $option, $value );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $notoptions_key = "$network_id:notoptions";
- $notoptions = wp_cache_get( $notoptions_key, 'site-options' );
-
- if ( is_array( $notoptions ) && isset( $notoptions[ $option ] ) ) {
- unset( $notoptions[ $option ] );
- wp_cache_set( $notoptions_key, $notoptions, 'site-options' );
- }
-
</del><span class="cx" style="display: block; padding: 0 10px"> if ( ! is_multisite() ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $result = update_option( $option, $value, 'no' );
</span><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $value = sanitize_option( $option, $value );
-
- $serialized_value = maybe_serialize( $value );
- $result = $wpdb->update(
- $wpdb->sitemeta,
- array( 'meta_value' => $serialized_value ),
- array(
- 'site_id' => $network_id,
- 'meta_key' => $option,
- )
- );
-
- if ( $result ) {
- $cache_key = "$network_id:$option";
- wp_cache_set( $cache_key, $value, 'site-options' );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $value = sanitize_option( $option, $value );
+ $result = update_metadata( 'site', $network_id, wp_slash( $option ), wp_slash( $value ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $result ) {
</span></span></pre></div>
<a id="trunktestsphpunittestsajaxCompressionphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/ajax/Compression.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/ajax/Compression.php 2022-09-06 02:50:35 UTC (rev 54079)
+++ trunk/tests/phpunit/tests/ajax/Compression.php 2022-09-06 11:26:45 UTC (rev 54080)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -154,7 +154,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Check the site option is not changed due to lack of nonce.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( 0, get_site_option( 'can_compress_scripts' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( 0, (int) get_site_option( 'can_compress_scripts' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Add a nonce.
</span><span class="cx" style="display: block; padding: 0 10px"> $_GET['_ajax_nonce'] = wp_create_nonce( 'update_can_compress_scripts' );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -167,7 +167,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Check the site option is changed.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( 1, get_site_option( 'can_compress_scripts' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( 1, (int) get_site_option( 'can_compress_scripts' ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -194,7 +194,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Check the site option is not changed due to lack of nonce.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( 1, get_site_option( 'can_compress_scripts' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( 1, (int) get_site_option( 'can_compress_scripts' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Add a nonce.
</span><span class="cx" style="display: block; padding: 0 10px"> $_GET['_ajax_nonce'] = wp_create_nonce( 'update_can_compress_scripts' );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -207,7 +207,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Check the site option is changed.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( 0, get_site_option( 'can_compress_scripts' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( 0, (int) get_site_option( 'can_compress_scripts' ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span></span></pre></div>
<a id="trunktestsphpunittestsoptionmultisitephp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/option/multisite.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/option/multisite.php 2022-09-06 02:50:35 UTC (rev 54079)
+++ trunk/tests/phpunit/tests/option/multisite.php 2022-09-06 11:26:45 UTC (rev 54080)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -153,28 +153,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @group multisite
- *
- * @covers ::get_site_option
- */
- public function test_site_notoptions() {
- $network_id = get_current_network_id();
- $notoptions_key = "{$network_id}:notoptions";
-
- $_notoptions = wp_cache_get( 'notoptions', 'site-options' );
- $this->assertEmpty( $_notoptions );
- $_notoptions1 = wp_cache_get( $notoptions_key, 'site-options' );
- $this->assertEmpty( $_notoptions1 );
-
- get_site_option( 'burrito' );
-
- $notoptions = wp_cache_get( 'notoptions', 'site-options' );
- $this->assertEmpty( $notoptions );
- $notoptions1 = wp_cache_get( $notoptions_key, 'site-options' );
- $this->assertNotEmpty( $notoptions1 );
- }
-
- /**
</del><span class="cx" style="display: block; padding: 0 10px"> * @covers ::users_can_register_signup_filter
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers ::get_site_option
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span></span></pre></div>
<a id="trunktestsphpunittestsoptionnetworkOptionphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/option/networkOption.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/option/networkOption.php 2022-09-06 02:50:35 UTC (rev 54079)
+++ trunk/tests/phpunit/tests/option/networkOption.php 2022-09-06 11:26:45 UTC (rev 54080)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -137,7 +137,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @ticket 43506
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @ticket 37181
+ *
</ins><span class="cx" style="display: block; padding: 0 10px"> * @group ms-required
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers ::get_network_option
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -144,51 +145,116 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers ::wp_cache_get
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers ::wp_cache_delete
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_get_network_option_sets_notoptions_if_option_found() {
- $network_id = get_current_network_id();
- $notoptions_key = "$network_id:notoptions";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_meta_api_use_values_in_network_option() {
+ $network_id = self::factory()->network->create();
+ $option = __FUNCTION__;
+ $value = __FUNCTION__;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $original_cache = wp_cache_get( $notoptions_key, 'site-options' );
- if ( false !== $original_cache ) {
- wp_cache_delete( $notoptions_key, 'site-options' );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_metadata( 'site', $network_id, $option, $value, true );
+ $this->assertEqualSets( get_metadata( 'site', $network_id, $option ), array( get_network_option( $network_id, $option, true ) ) );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Retrieve any existing option.
- get_network_option( $network_id, 'site_name' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 37181
+ *
+ * @group ms-required
+ */
+ function test_funky_network_meta() {
+ $network_id = self::factory()->network->create();
+ $option = __FUNCTION__;
+ $classy = new StdClass();
+ $classy->ID = 1;
+ $classy->stringy = 'I love slashes\\\\';
+ $funky_meta[] = $classy;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $cache = wp_cache_get( $notoptions_key, 'site-options' );
- if ( false !== $original_cache ) {
- wp_cache_set( $notoptions_key, $original_cache, 'site-options' );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $classy = new StdClass();
+ $classy->ID = 2;
+ $classy->stringy = 'I love slashes\\\\ more';
+ $funky_meta[] = $classy;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( array(), $cache );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Add a network meta item.
+ $this->assertIsInt( add_metadata( 'site', $network_id, $option, $funky_meta, true ) );
+
+ // Check they exists.
+ $this->assertEquals( $funky_meta, get_network_option( $network_id, $option ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @ticket 43506
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @ticket 37181
+ *
</ins><span class="cx" style="display: block; padding: 0 10px"> * @group ms-required
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ */
+ public function test_meta_api_multiple_values_in_network_option() {
+ $network_id = self::factory()->network->create();
+ $option = __FUNCTION__;
+ add_metadata( 'site', $network_id, $option, 'monday', true );
+ add_metadata( 'site', $network_id, $option, 'tuesday', true );
+ add_metadata( 'site', $network_id, $option, 'wednesday', true );
+ $this->assertEquals( 'monday', get_network_option( $network_id, $option, true ) );
+ }
+
+ /**
+ * @ticket 37181
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @group ms-required
+ *
</ins><span class="cx" style="display: block; padding: 0 10px"> * @covers ::get_network_option
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers ::wp_cache_get
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_get_network_option_sets_notoptions_if_option_not_found() {
- $network_id = get_current_network_id();
- $notoptions_key = "$network_id:notoptions";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_network_option_count_queries_on_non_existing() {
+ $network_id = self::factory()->network->create();
+ $option = __FUNCTION__;
+ add_network_option( $network_id, $option, 'monday' );
+ get_network_option( $network_id, $option );
+ $num_queries_pre_get = get_num_queries();
+ get_network_option( $network_id, 'do_not_exist' );
+ $num_queries_after_get = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $original_cache = wp_cache_get( $notoptions_key, 'site-options' );
- if ( false !== $original_cache ) {
- wp_cache_delete( $notoptions_key, 'site-options' );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $num_queries_pre_get, $num_queries_after_get );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Retrieve any non-existing option.
- get_network_option( $network_id, 'this_does_not_exist' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 37181
+ *
+ * @group ms-required
+ */
+ public function test_register_meta_network_option_single_false() {
+ $network_id = self::factory()->network->create();
+ $option = __FUNCTION__;
+ $value = __FUNCTION__;
+ register_meta(
+ 'site',
+ $option,
+ array(
+ 'type' => 'string',
+ 'default' => $value,
+ 'single' => false,
+ )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $cache = wp_cache_get( $notoptions_key, 'site-options' );
- if ( false !== $original_cache ) {
- wp_cache_set( $notoptions_key, $original_cache, 'site-options' );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $value, get_network_option( $network_id, $option ) );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( array( 'this_does_not_exist' => true ), $cache );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 37181
+ *
+ * @group ms-required
+ */
+ public function test_register_meta_network_option_single_true() {
+ $network_id = self::factory()->network->create();
+ $option = __FUNCTION__;
+ $value = __FUNCTION__;
+ register_meta(
+ 'site',
+ $option,
+ array(
+ 'type' => 'string',
+ 'default' => $value,
+ 'single' => true,
+ )
+ );
+
+ $this->assertSame( $value, get_network_option( $network_id, $option ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -196,9 +262,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 44956
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @group ms-required
+ *
</ins><span class="cx" style="display: block; padding: 0 10px"> * @covers ::update_network_option
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_update_network_option_array_with_object() {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $network_id = self::factory()->network->create();
+ $option = __FUNCTION__;
</ins><span class="cx" style="display: block; padding: 0 10px"> $array_w_object = array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'url' => 'http://src.wordpress-develop.dev/wp-content/uploads/2016/10/cropped-Blurry-Lights.jpg',
</span><span class="cx" style="display: block; padding: 0 10px"> 'meta_data' => (object) array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -208,24 +278,140 @@
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $array_w_object_2 = array(
- 'url' => 'http://src.wordpress-develop.dev/wp-content/uploads/2016/10/cropped-Blurry-Lights.jpg',
- 'meta_data' => (object) array(
- 'attachment_id' => 292,
- 'height' => 708,
- 'width' => 1260,
- ),
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_metadata( 'site', $network_id, $option, $array_w_object, true );
+ $this->assertEquals( $array_w_object, get_network_option( $network_id, $option ) );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Add the option, it did not exist before this.
- add_network_option( null, 'array_w_object', $array_w_object );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 37181
+ *
+ * @group ms-required
+ *
+ * @covers ::add_network_option
+ *
+ * @dataProvider data_types_options
+ */
+ public function test_type_add_network_option( $name, $value, $expected ) {
+ $result = add_network_option( null, $name, $value );
+ $this->assertTrue( $result, 'Network option was not added' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $num_queries_pre_update = get_num_queries();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $test_value = get_network_option( null, $name );
+ $this->assertSame( $expected, $test_value, 'Values do not match' );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Update the option using the same array with an object for the value.
- $this->assertFalse( update_network_option( null, 'array_w_object', $array_w_object_2 ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 37181
+ *
+ * @covers ::add_network_option
+ *
+ * @dataProvider data_slashed_options
+ */
+ public function test_slash_add_network_option( $name, $value ) {
+ $result = add_network_option( null, $name, $value );
+ $this->assertTrue( $result, 'Network option was not added' );
+ $this->assertSame( $value, get_network_option( null, $name ), 'Values do not match' );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Check that no new database queries were performed.
- $this->assertSame( $num_queries_pre_update, get_num_queries() );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 37181
+ *
+ * @covers ::update_network_option
+ *
+ * @dataProvider data_slashed_options
+ */
+ public function test_slash_update_network_option( $name, $value ) {
+ $result = update_network_option( null, $name, $value );
+ $this->assertTrue( $result, 'Network option was not updated' );
+ $this->assertSame( $value, get_network_option( null, $name ), 'Values do not match' );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ /**
+ * @ticket 37181
+ *
+ * @covers ::delete_network_option()
+ *
+ * @dataProvider data_slashed_options
+ */
+ public function test_slash_delete_network_option( $name, $value ) {
+ $result = add_network_option( null, $name, $value );
+ $this->assertTrue( $result, 'Network option was not added' );
+ $this->assertSame( $value, get_network_option( null, $name ) );
+ $result = delete_network_option( null, $name );
+ $this->assertTrue( $result, 'Network option was not deleted' );
+ $this->assertFalse( get_network_option( null, $name ), 'Network option was not deleted' );
+ }
+
+ public function data_slashed_options() {
+ return array(
+ 'slashed option name' => array(
+ 'option' => 'String with 1 slash \\',
+ 'value' => 'foo',
+ ),
+ 'slashed in middle option name' => array(
+ 'option' => 'String\\thing',
+ 'value' => 'foo',
+ ),
+ 'slashed option value' => array(
+ 'option' => 'bar',
+ 'value' => 'String with 1 slash \\',
+ ),
+ 'slashed option name and value' => array(
+ 'option' => 'String with 1 slash \\',
+ 'value' => 'String with 1 slash \\',
+ ),
+ 'slashed 4 times option name and value' => array(
+ 'option' => 'String with 4 slashes \\\\\\\\',
+ 'value' => 'String with 4 slashes \\\\\\\\',
+ ),
+ 'slashed 7 times option name and value' => array(
+ 'option' => 'String with 7 slashes \\\\\\\\\\\\\\',
+ 'value' => 'String with 7 slashes \\\\\\\\\\\\\\',
+ ),
+ );
+ }
+
+ public function data_types_options() {
+ return array(
+ 'array' => array(
+ 'option' => 'array',
+ 'value' => array(),
+ 'expected' => array(),
+ ),
+ 'array_keys' => array(
+ 'option' => 'array',
+ 'value' => array( 'key' => 'value' ),
+ 'expected' => array( 'key' => 'value' ),
+ ),
+ 'int' => array(
+ 'option' => 'int',
+ 'value' => 33,
+ 'expected' => '33',
+ ),
+ 'string' => array(
+ 'option' => 'string',
+ 'value' => 'foo',
+ 'expected' => 'foo',
+ ),
+ 'string_bool' => array(
+ 'option' => 'string',
+ 'value' => 'true',
+ 'expected' => 'true',
+ ),
+ 'float' => array(
+ 'option' => 'float',
+ 'value' => 33.5555,
+ 'expected' => '33.5555',
+ ),
+ 'bool' => array(
+ 'option' => 'bool',
+ 'value' => true,
+ 'expected' => '1',
+ ),
+ 'null' => array(
+ 'option' => 'null',
+ 'value' => null,
+ 'expected' => null,
+ ),
+ );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre>
</div>
</div>
</body>
</html>