Make WordPress Core

Ticket #41039: 41039.2.diff

File 41039.2.diff, 2.2 KB (added by dlh, 9 years ago)
  • src/wp-includes/functions.php

     
    33033303 * @access private
    33043304 */
    33053305function _delete_option_fresh_site() {
    3306         update_option( 'fresh_site', 0 );
     3306        update_option( 'fresh_site', '0' );
    33073307}
    33083308
    33093309/**
  • tests/phpunit/tests/customize/manager.php

     
    170170                $this->assertInstanceOf( 'WPDieException', $exception );
    171171                $this->assertContains( 'Invalid changeset UUID', $exception->getMessage() );
    172172
    173                 update_option( 'fresh_site', 0 );
     173                update_option( 'fresh_site', '0' );
    174174                $wp_customize = new WP_Customize_Manager();
    175175                $wp_customize->setup_theme();
    176176                $this->assertFalse( has_action( 'after_setup_theme', array( $wp_customize, 'import_theme_starter_content' ) ) );
    177177
    178178                // Make sure that starter content import gets queued on a fresh site.
    179                 update_option( 'fresh_site', 1 );
     179                update_option( 'fresh_site', '1' );
    180180                $wp_customize->setup_theme();
    181181                $this->assertEquals( 100, has_action( 'after_setup_theme', array( $wp_customize, 'import_theme_starter_content' ) ) );
    182182        }
    183183
    184184        /**
     185         * Test that clearing a fresh site is a no-op if the site is already fresh.
     186         *
     187         * @ticket 38991
     188         */
     189        function test_fresh_site_flag_clearing() {
     190                global $wp_customize, $wpdb;
     191
     192                // Make sure fresh site flag is cleared when publishing a changeset.
     193                update_option( 'fresh_site', '1' );
     194                do_action( 'customize_save_after', $wp_customize );
     195                $this->assertEquals( '0', get_option( 'fresh_site' ) );
     196
     197                // Simulate a new, uncached request.
     198                wp_cache_delete( 'alloptions', 'options' );
     199                wp_load_alloptions();
     200
     201                // Make sure no DB write is done when publishing and a site is already non-fresh.
     202                $query_count = $wpdb->num_queries;
     203                do_action( 'customize_save_after', $wp_customize );
     204                $this->assertSame( $query_count, $wpdb->num_queries );
     205        }
     206
     207        /**
    185208         * Test WP_Customize_Manager::setup_theme() for frontend.
    186209         *
    187210         * @covers WP_Customize_Manager::setup_theme()