Make WordPress Core


Ignore:
Timestamp:
04/16/2016 07:47:14 PM (9 years ago)
Author:
jeremyfelt
Message:

Options: Do not set network options to autoload in single site

When multisite is not configured, the _site_transient() and _site_option() functions fallback to _option() and store network "meta/options" in wp_options.

Previously, those calls to _option() did not explicitly set the autoload parameter and anything assigned as a transient or option at the network level would be set to autoload by default, even though autoload is not yet a concept at the network option level.

This changes that behavior and forces the autoload setting to no. If autoload is desired, the single site option functions should be used.

Props thomaswm.
Fixes #22846.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/option/networkOption.php

    r37222 r37223  
    5454
    5555    /**
     56     * @ticket 22846
     57     */
     58    public function test_add_network_option_is_not_stored_as_autoload_option() {
     59        $key = rand_str();
     60
     61        if ( is_multisite() ) {
     62            $this->markTestSkipped( 'Does not apply when used in multisite.' );
     63        }
     64
     65        add_network_option( null, $key, 'Not an autoload option' );
     66
     67        $options = wp_load_alloptions();
     68
     69        $this->assertFalse( isset( $options[ $key ] ) );
     70    }
     71
     72    /**
     73     * @ticket 22846
     74     */
     75    public function test_update_network_option_is_not_stored_as_autoload_option() {
     76        $key = rand_str();
     77
     78        if ( is_multisite() ) {
     79            $this->markTestSkipped( 'Does not apply when used in multisite.' );
     80        }
     81
     82        update_network_option( null, $key, 'Not an autoload option' );
     83
     84        $options = wp_load_alloptions();
     85
     86        $this->assertFalse( isset( $options[ $key ] ) );
     87    }
     88
     89    /**
    5690     * @dataProvider data_network_id_parameter
    5791     *
Note: See TracChangeset for help on using the changeset viewer.