WordPress.org

Make WordPress Core

Changeset 35024


Ignore:
Timestamp:
10/11/2015 10:43:59 PM (4 years ago)
Author:
jeremyfelt
Message:

MS: Adjust _network_option() parameter order, $network_id is first.

This better aligns with expectations and matches the structure used by _blog_option(). The _site_option() functions remain as an appropriate method for working with the current network.

See #28290.

Location:
trunk
Files:
4 edited

Legend:

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

    r34819 r35024  
    146146
    147147        $default = ucfirst( $this->domain );
    148         $this->site_name = get_network_option( 'site_name', $default, $this->id );
     148        $this->site_name = get_network_option( $this->id, 'site_name', $default );
    149149    }
    150150
  • trunk/src/wp-includes/ms-functions.php

    r35016 r35024  
    13441344    if ( ! is_subdomain_install() ) {
    13451345
    1346         if ( 'https' === parse_url( get_network_option( 'siteurl' ), PHP_URL_SCHEME ) ) {
     1346        if ( 'https' === parse_url( get_site_option( 'siteurl' ), PHP_URL_SCHEME ) ) {
    13471347            $siteurl = set_url_scheme( $siteurl, 'https' );
    13481348        }
  • trunk/src/wp-includes/option.php

    r34931 r35024  
    10001000 */
    10011001function get_site_option( $option, $default = false, $deprecated = true ) {
    1002     return get_network_option( $option, $default );
     1002    return get_network_option( null, $option, $default );
    10031003}
    10041004
     
    10181018 */
    10191019function add_site_option( $option, $value ) {
    1020     return add_network_option( $option, $value );
     1020    return add_network_option( null, $option, $value );
    10211021}
    10221022
     
    10331033 */
    10341034function delete_site_option( $option ) {
    1035     return delete_network_option( $option );
     1035    return delete_network_option( null, $option );
    10361036}
    10371037
     
    10491049 */
    10501050function update_site_option( $option, $value ) {
    1051     return update_network_option( $option, $value );
     1051    return update_network_option( null, $option, $value );
    10521052}
    10531053
     
    10621062 * @global object $current_site
    10631063 *
     1064 * @param int      $network_id ID of the network. Can be null to default to the current network ID.
    10641065 * @param string   $option     Name of option to retrieve. Expected to not be SQL-escaped.
    10651066 * @param mixed    $default    Optional. Value to return if the option doesn't exist. Default false.
    1066  * @param int|bool $network_id Optional. ID of the network. Defaults to current network ID.
    10671067 * @return mixed Value set for the option.
    10681068 */
    1069 function get_network_option( $option, $default = false, $network_id = false ) {
     1069function get_network_option( $network_id, $option, $default = false ) {
    10701070    global $wpdb, $current_site;
    10711071
     
    11751175 * @global object $current_site
    11761176 *
    1177  * @param  string   $option     Name of option to add. Expected to not be SQL-escaped.
    1178  * @param  mixed    $value      Option value, can be anything. Expected to not be SQL-escaped.
    1179  * @param  int|bool $network_id Optional. ID of the network. Defaults to current network ID.
     1177 * @param int    $network_id ID of the network. Can be null to default to the current network ID.
     1178 * @param string $option     Name of option to add. Expected to not be SQL-escaped.
     1179 * @param mixed  $value      Option value, can be anything. Expected to not be SQL-escaped.
    11801180 * @return bool False if option was not added and true if option was added.
    11811181 */
    1182 function add_network_option( $option, $value, $network_id = false ) {
     1182function add_network_option( $network_id, $option, $value ) {
    11831183    global $wpdb, $current_site;
    11841184
     
    12161216        $notoptions = wp_cache_get( $notoptions_key, 'site-options' );
    12171217        if ( ! is_array( $notoptions ) || ! isset( $notoptions[ $option ] ) ) {
    1218             if ( false !== get_network_option( $option, false, $network_id ) ) {
     1218            if ( false !== get_network_option( $network_id, $option, false ) ) {
    12191219                return false;
    12201220            }
     
    12811281 * @global object $current_site
    12821282 *
    1283  * @param  string   $option     Name of option to remove. Expected to not be SQL-escaped.
    1284  * @param  int|bool $network_id Optional. ID of the network. Defaults to current network ID.
     1283 * @param int    $network_id ID of the network. Can be null to default to the current network ID.
     1284 * @param string $option     Name of option to remove. Expected to not be SQL-escaped.
    12851285 * @return bool True, if succeed. False, if failure.
    12861286 */
    1287 function delete_network_option( $option, $network_id = false ) {
     1287function delete_network_option( $network_id, $option ) {
    12881288    global $wpdb, $current_site;
    12891289
     
    13591359 * @global object $current_site
    13601360 *
     1361 * @param int      $network_id ID of the network. Can be null to default to the current network ID.
    13611362 * @param string   $option     Name of option. Expected to not be SQL-escaped.
    13621363 * @param mixed    $value      Option value. Expected to not be SQL-escaped.
    1363  * @param int|bool $network_id Optional. ID of the network. Defaults to current network ID.
    13641364 * @return bool False if value was not updated and true if value was updated.
    13651365 */
    1366 function update_network_option( $option, $value, $network_id = false ) {
     1366function update_network_option( $network_id, $option, $value ) {
    13671367    global $wpdb, $current_site;
    13681368
     
    13761376    wp_protect_special_option( $option );
    13771377
    1378     $old_value = get_network_option( $option, false, $network_id );
     1378    $old_value = get_network_option( $network_id, $option, false );
    13791379
    13801380    /**
     
    13981398
    13991399    if ( false === $old_value ) {
    1400         return add_network_option( $option, $value, $network_id );
     1400        return add_network_option( $network_id, $option, $value );
    14011401    }
    14021402
  • trunk/tests/phpunit/tests/option/networkOption.php

    r34777 r35024  
    1616        $value = rand_str();
    1717
    18         add_network_option( $option, $value );
    19         $this->assertFalse( get_network_option( $option, false, $id ) );
     18        add_site_option( $option, $value );
     19        $this->assertFalse( get_network_option( $id, $option, false ) );
    2020    }
    2121
     
    2525        $value = rand_str();
    2626
    27         add_network_option( $option, $value, $id );
    28         $this->assertEquals( $value, get_network_option( $option, false, $id ) );
     27        add_network_option( $id, $option, $value );
     28        $this->assertEquals( $value, get_network_option( $id, $option, false ) );
    2929    }
    3030
     
    3434        $value = rand_str();
    3535
    36         add_network_option( $option, $value );
    37         add_network_option( $option, $value, $id );
    38         delete_network_option( $option );
    39         $this->assertEquals( $value, get_network_option( $option, false, $id ) );
     36        add_site_option( $option, $value );
     37        add_network_option( $id, $option, $value );
     38        delete_site_option( $option );
     39        $this->assertEquals( $value, get_network_option( $id, $option, false ) );
    4040    }
    4141}
Note: See TracChangeset for help on using the changeset viewer.