[wp-trac] [WordPress Trac] #37181: Use metadata api in *_network_options

WordPress Trac noreply at wordpress.org
Wed Dec 20 13:49:07 UTC 2017


#37181: Use metadata api in *_network_options
-------------------------------------------------+-------------------------
 Reporter:  spacedmonkey                         |       Owner:
     Type:  enhancement                          |      Status:  reopened
 Priority:  normal                               |   Milestone:  5.0
Component:  Networks and Sites                   |     Version:  4.4
 Severity:  normal                               |  Resolution:
 Keywords:  has-patch ms-roadmap dev-feedback    |     Focuses:  multisite
  has-unit-tests                                 |
-------------------------------------------------+-------------------------

Comment (by spacedmonkey):

 Some things to not

 - All options will be loaded in one cache key. This may effect people with
 lots of network options, however, not many people use network options, it
 is unlike to be a problem.
 - Even through all options are loaded at once, it is not effected by the
 alloptions issue, detailed in #31245 . This because the meta api, does a
 delete instead of update. See
 [https://github.com/WordPress/WordPress/blob/fe24185f48a5fd27294c1251de7047c54fe178ca
 /wp-includes/meta.php#L107 here]
 - Network options will now be primed in `WP_Network_Query`, meaning
 network options will be loaded
 in the bootstrap, which I think is is a good thing.
 - In my patch, I run `maybe_serialize` before passing to the meta api.
 Howeve the meta api also serialize. I dont think there is a problem with
 double serializing something?
 - Many of the existing filters could be moved out of the filters / actions
 in these could be moved out to there own functions. Consider the following
 example.
 {{{#!php
 add_filter('get_site_metadata', function($value, $network_id, $option){
    $pre = apply_filters( "pre_site_option_{$option}", false, $option,
 $network_id );
    if ( false !== $pre ) {
         $value = $pre;
    }
    return $value;
 }, 5, 3);

 }}}
 This allows for backward compat, but also if to remove those filters if
 you don't wish to use them anymore. This may over complex things.
 - clean_network_cache now clears network options, which I think it should
 be doing already. This means that the [https://github.com/stuttter/wp-
 multi-network/blob/66ac5b8bb2c9082c49b0b06fc4830006a3151d5c/wp-multi-
 network/includes/functions.php#L799 delete_network] function in wp-multi-
 network, it work better. ( Good work @johnjamesjacoby on that one ).

--
Ticket URL: <https://core.trac.wordpress.org/ticket/37181#comment:44>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list