Make WordPress Core


Ignore:
Timestamp:
01/05/2017 07:12:23 AM (10 years ago)
Author:
westonruter
Message:

Customize: Ensure theme_mod-cache of custom_css lookup of -1 short-circuits a WP_Query from being made.

Props dlh.
See #35395.
Fixes #39259.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/customize/custom-css-setting.php

    r39559 r39688  
    136136                $twentyten_setting = new WP_Customize_Custom_CSS_Setting( $this->wp_customize, 'custom_css[twentyten]' );
    137137
     138                remove_theme_mod( 'custom_css_post_id' );
     139
    138140                $this->assertEquals( $post_id, wp_get_custom_css_post()->ID );
    139141                $this->assertEquals( $post_id, wp_get_custom_css_post( $this->setting->stylesheet )->ID );
     
    222224
    223225        /**
     226         * Test that wp_get_custom_css_post() doesn't query for a post after caching a failed lookup.
     227         *
     228         * @ticket 39259
     229         */
     230        function test_get_custom_css_post_queries_after_failed_lookup() {
     231                set_theme_mod( 'custom_css_post_id', -1 );
     232                $queries_before = get_num_queries();
     233                wp_get_custom_css_post();
     234                $this->assertSame( get_num_queries(), $queries_before );
     235        }
     236
     237        /**
     238         * Test that wp_update_custom_css_post() updates the 'custom_css_post_id' theme mod.
     239         *
     240         * @ticket 39259
     241         */
     242        function test_update_custom_css_updates_theme_mod() {
     243                set_theme_mod( 'custom_css_post_id', -1 );
     244                $post = wp_update_custom_css_post( 'body { background: blue; }' );
     245                $this->assertSame( $post->ID, get_theme_mod( 'custom_css_post_id' ) );
     246        }
     247
     248        /**
    224249         * Test crud methods on WP_Customize_Custom_CSS_Setting.
    225250         *
     
    238263                        'post_type' => 'custom_css',
    239264                ) );
     265                remove_theme_mod( 'custom_css_post_id' );
    240266                $this->assertEquals( '/*custom*//*filtered*/', $this->setting->value() );
    241267
Note: See TracChangeset for help on using the changeset viewer.