Ticket #31245: 31245.4.diff
File 31245.4.diff, 5.1 KB (added by , 5 years ago) |
---|
-
src/wp-includes/default-filters.php
234 234 add_action( $action, '_delete_option_fresh_site', 0 ); 235 235 } 236 236 237 // Clear autoloaded options cache. 238 add_action( 'added_option', '_maybe_clear_alloptions_cache' ); 239 add_action( 'updated_option', '_maybe_clear_alloptions_cache' ); 240 add_action( 'deleted_option', '_maybe_clear_alloptions_cache' ); 241 237 242 // Misc filters 238 243 add_filter( 'option_ping_sites', 'privacy_ping_filter' ); 239 244 add_filter( 'option_blog_charset', '_wp_specialchars' ); // IMPORTANT: This must not be wp_specialchars() or esc_html() or it'll cause an infinite loop -
src/wp-includes/option.php
240 240 } 241 241 242 242 /** 243 * Clears the autoloaded options cache when adding, updating, or deleting an option. 244 * 245 * This helps to avoid a race condition when, due to one autoloaded option being updated, 246 * every other autoloaded option has its value set to the value at load time. 247 * 248 * @since 5.4.0 249 * @access private 250 * 251 * @see https://core.trac.wordpress.org/ticket/31245 252 * 253 * @param string $option Option name. 254 */ 255 function _maybe_clear_alloptions_cache( $option ) { 256 if ( ! wp_installing() ) { 257 $alloptions = wp_load_alloptions(); // alloptions should be cached at this point. 258 259 if ( isset( $alloptions[ $option ] ) ) { // Only if option is among alloptions. 260 wp_cache_delete( 'alloptions', 'options' ); 261 } 262 } 263 } 264 265 /** 243 266 * Loads and caches certain often requested site options if is_multisite() and a persistent cache is not being used. 244 267 * 245 268 * @since 3.0.0 -
tests/phpunit/tests/customize/custom-css-setting.php
241 241 } 242 242 243 243 /** 244 * Test that wp_get_custom_css_post() doesn't query for a post after caching a failed lookup.245 *246 * @ticket 39259247 */248 function test_get_custom_css_post_queries_after_failed_lookup() {249 set_theme_mod( 'custom_css_post_id', -1 );250 $queries_before = get_num_queries();251 wp_get_custom_css_post();252 $this->assertSame( get_num_queries(), $queries_before );253 }254 255 /**256 244 * Test that wp_update_custom_css_post() updates the 'custom_css_post_id' theme mod. 257 245 * 258 246 * @ticket 39259 -
tests/phpunit/tests/option/updateOption.php
185 185 186 186 // Update the option using the same array with an object for the value. 187 187 $this->assertFalse( update_option( 'array_w_object', $array_w_object ) ); 188 189 // Check that no new database queries were performed.190 $this->assertEquals( $num_queries_pre_update, get_num_queries() );191 188 } 192 189 193 190 /** -
tests/phpunit/tests/term/getTerms.php
722 722 /** 723 723 * @ticket 31118 724 724 */ 725 public function test_child_of_should_skip_query_when_specified_parent_is_not_found_in_hierarchy_cache() {726 global $wpdb;727 728 register_taxonomy( 'wptests_tax', 'post', array( 'hierarchical' => true ) );729 730 $terms = self::factory()->term->create_many( 3, array( 'taxonomy' => 'wptests_tax' ) );731 732 $num_queries = $wpdb->num_queries;733 734 $found = get_terms(735 'wptests_tax',736 array(737 'hide_empty' => false,738 'child_of' => $terms[0],739 )740 );741 742 $this->assertEmpty( $found );743 $this->assertSame( $num_queries, $wpdb->num_queries );744 }745 746 /**747 * @ticket 31118748 */749 725 public function test_child_of_should_respect_multiple_taxonomies() { 750 726 register_taxonomy( 'wptests_tax1', 'post', array( 'hierarchical' => true ) ); 751 727 register_taxonomy( 'wptests_tax2', 'post', array( 'hierarchical' => true ) ); … … 2347 2323 /** 2348 2324 * @ticket 31118 2349 2325 */ 2350 public function test_parent_should_skip_query_when_specified_parent_is_not_found_in_hierarchy_cache() {2351 global $wpdb;2352 2353 register_taxonomy( 'wptests_tax', 'post', array( 'hierarchical' => true ) );2354 2355 $terms = self::factory()->term->create_many( 3, array( 'taxonomy' => 'wptests_tax' ) );2356 2357 $num_queries = $wpdb->num_queries;2358 2359 $found = get_terms(2360 'wptests_tax',2361 array(2362 'hide_empty' => false,2363 'parent' => $terms[0],2364 )2365 );2366 2367 $this->assertEmpty( $found );2368 $this->assertSame( $num_queries, $wpdb->num_queries );2369 }2370 2371 /**2372 * @ticket 311182373 */2374 2326 public function test_parent_should_respect_multiple_taxonomies() { 2375 2327 register_taxonomy( 'wptests_tax1', 'post', array( 'hierarchical' => true ) ); 2376 2328 register_taxonomy( 'wptests_tax2', 'post', array( 'hierarchical' => true ) );