Ticket #21401: using-ext-function.diff
File using-ext-function.diff, 8.3 KB (added by , 13 years ago) |
---|
-
wp-includes/load.php
372 372 } 373 373 374 374 /** 375 * Access/Modify private global variable $_wp_using_ext_object_cache 376 * 377 * Toggle $_wp_using_ext_object_cache on and off without directly touching global 378 * 379 * @since 3.5.0 380 * 381 * @param bool $using Whether external object cache is being used 382 * @return bool The current 'using' setting 383 */ 384 function wp_using_ext_object_cache( $using = null ) { 385 global $_wp_using_ext_object_cache; 386 $current_using = $_wp_using_ext_object_cache; 387 if ( null !== $using ) 388 $_wp_using_ext_object_cache = $using; 389 return $current_using; 390 } 391 392 /** 375 393 * Starts the WordPress object cache. 376 394 * 377 395 * If an object-cache.php file exists in the wp-content directory, … … 381 399 * @since 3.0.0 382 400 */ 383 401 function wp_start_object_cache() { 384 global $_wp_using_ext_object_cache;385 386 402 $first_init = false; 387 403 if ( ! function_exists( 'wp_cache_init' ) ) { 388 404 if ( file_exists( WP_CONTENT_DIR . '/object-cache.php' ) ) { 389 405 require_once ( WP_CONTENT_DIR . '/object-cache.php' ); 390 $_wp_using_ext_object_cache = true; 391 } else { 392 require_once ( ABSPATH . WPINC . '/cache.php' ); 393 $_wp_using_ext_object_cache = false; 406 if ( function_exists( 'wp_cache_init' ) ) 407 wp_using_ext_object_cache( true ); 394 408 } 409 395 410 $first_init = true; 396 } else if ( ! $_wp_using_ext_object_cache&& file_exists( WP_CONTENT_DIR . '/object-cache.php' ) ) {411 } else if ( !wp_using_ext_object_cache() && file_exists( WP_CONTENT_DIR . '/object-cache.php' ) ) { 397 412 // Sometimes advanced-cache.php can load object-cache.php before it is loaded here. 398 413 // This breaks the function_exists check above and can result in $_wp_using_ext_object_cache 399 414 // being set incorrectly. Double check if an external cache exists. 400 $_wp_using_ext_object_cache = true;415 wp_using_ext_object_cache( true ); 401 416 } 402 417 418 if ( ! wp_using_ext_object_cache() ) 419 require_once ( ABSPATH . WPINC . '/cache.php' ); 420 403 421 // If cache supports reset, reset instead of init if already initialized. 404 422 // Reset signals to the cache that global IDs have changed and it may need to update keys 405 423 // and cleanup caches. 406 if ( !$first_init && function_exists( 'wp_cache_reset') )424 if ( !$first_init && function_exists( 'wp_cache_reset' ) ) 407 425 wp_cache_reset(); 408 else 426 elseif ( function_exists( 'wp_cache_init' ) ) 409 427 wp_cache_init(); 410 428 411 429 if ( function_exists( 'wp_cache_add_global_groups' ) ) { -
wp-includes/query.php
1915 1915 * @return array List of posts. 1916 1916 */ 1917 1917 function &get_posts() { 1918 global $wpdb, $user_ID , $_wp_using_ext_object_cache;1918 global $wpdb, $user_ID; 1919 1919 1920 1920 $this->parse_query(); 1921 1921 … … 1965 1965 $q['suppress_filters'] = false; 1966 1966 1967 1967 if ( !isset($q['cache_results']) ) { 1968 if ( $_wp_using_ext_object_cache)1968 if ( wp_using_ext_object_cache() ) 1969 1969 $q['cache_results'] = false; 1970 1970 else 1971 1971 $q['cache_results'] = true; -
wp-includes/option.php
166 166 * @param int $site_id Optional site ID for which to query the options. Defaults to the current site. 167 167 */ 168 168 function wp_load_core_site_options( $site_id = null ) { 169 global $wpdb , $_wp_using_ext_object_cache;169 global $wpdb; 170 170 171 if ( !is_multisite() || $_wp_using_ext_object_cache|| defined( 'WP_INSTALLING' ) )171 if ( !is_multisite() || wp_using_ext_object_cache() || defined( 'WP_INSTALLING' ) ) 172 172 return; 173 173 174 174 if ( empty($site_id) ) … … 401 401 * @return bool true if successful, false otherwise 402 402 */ 403 403 function delete_transient( $transient ) { 404 global $_wp_using_ext_object_cache;405 406 404 do_action( 'delete_transient_' . $transient, $transient ); 407 405 408 if ( $_wp_using_ext_object_cache) {406 if ( wp_using_ext_object_cache() ) { 409 407 $result = wp_cache_delete( $transient, 'transient' ); 410 408 } else { 411 409 $option_timeout = '_transient_timeout_' . $transient; … … 440 438 * @return mixed Value of transient 441 439 */ 442 440 function get_transient( $transient ) { 443 global $_wp_using_ext_object_cache;444 445 441 $pre = apply_filters( 'pre_transient_' . $transient, false ); 446 442 if ( false !== $pre ) 447 443 return $pre; 448 444 449 if ( $_wp_using_ext_object_cache) {445 if ( wp_using_ext_object_cache() ) { 450 446 $value = wp_cache_get( $transient, 'transient' ); 451 447 } else { 452 448 $transient_option = '_transient_' . $transient; … … 489 485 * @return bool False if value was not set and true if value was set. 490 486 */ 491 487 function set_transient( $transient, $value, $expiration = 0 ) { 492 global $_wp_using_ext_object_cache;493 494 488 $value = apply_filters( 'pre_set_transient_' . $transient, $value ); 495 489 496 if ( $_wp_using_ext_object_cache) {490 if ( wp_using_ext_object_cache() ) { 497 491 $result = wp_cache_set( $transient, $value, 'transient', $expiration ); 498 492 } else { 499 493 $transient_timeout = '_transient_timeout_' . $transient; … … 932 926 * @return bool True if successful, false otherwise 933 927 */ 934 928 function delete_site_transient( $transient ) { 935 global $_wp_using_ext_object_cache;936 937 929 do_action( 'delete_site_transient_' . $transient, $transient ); 938 if ( $_wp_using_ext_object_cache) {930 if ( wp_using_ext_object_cache() ) { 939 931 $result = wp_cache_delete( $transient, 'site-transient' ); 940 932 } else { 941 933 $option_timeout = '_site_transient_timeout_' . $transient; … … 970 962 * @return mixed Value of transient 971 963 */ 972 964 function get_site_transient( $transient ) { 973 global $_wp_using_ext_object_cache;974 975 965 $pre = apply_filters( 'pre_site_transient_' . $transient, false ); 976 966 if ( false !== $pre ) 977 967 return $pre; 978 968 979 if ( $_wp_using_ext_object_cache) {969 if ( wp_using_ext_object_cache() ) { 980 970 $value = wp_cache_get( $transient, 'site-transient' ); 981 971 } else { 982 972 // Core transients that do not have a timeout. Listed here so querying timeouts can be avoided. … … 1019 1009 * @return bool False if value was not set and true if value was set. 1020 1010 */ 1021 1011 function set_site_transient( $transient, $value, $expiration = 0 ) { 1022 global $_wp_using_ext_object_cache;1023 1024 1012 $value = apply_filters( 'pre_set_site_transient_' . $transient, $value ); 1025 1013 1026 if ( $_wp_using_ext_object_cache) {1014 if ( wp_using_ext_object_cache() ) { 1027 1015 $result = wp_cache_set( $transient, $value, 'site-transient', $expiration ); 1028 1016 } else { 1029 1017 $transient_timeout = '_site_transient_timeout_' . $transient; -
wp-includes/nav-menu.php
468 468 * @return mixed $items array of menu items, else false. 469 469 */ 470 470 function wp_get_nav_menu_items( $menu, $args = array() ) { 471 global $_wp_using_ext_object_cache;472 473 471 $menu = wp_get_nav_menu_object( $menu ); 474 472 475 473 if ( ! $menu ) … … 497 495 return false; 498 496 499 497 // Get all posts and terms at once to prime the caches 500 if ( empty( $fetched[$menu->term_id] ) || $_wp_using_ext_object_cache) {498 if ( empty( $fetched[$menu->term_id] ) || wp_using_ext_object_cache() ) { 501 499 $fetched[$menu->term_id] = true; 502 500 $posts = array(); 503 501 $terms = array(); -
wp-settings.php
55 55 wp_debug_mode(); 56 56 57 57 // For an advanced caching plugin to use. Uses a static drop-in because you would only want one. 58 if ( WP_CACHE )58 if ( WP_CACHE && file_exists( WP_CONTENT_DIR . '/advanced-cache.php' ) ) 59 59 WP_DEBUG ? include( WP_CONTENT_DIR . '/advanced-cache.php' ) : @include( WP_CONTENT_DIR . '/advanced-cache.php' ); 60 60 61 61 // Define WP_LANG_DIR if not set. -
wp-cron.php
28 28 29 29 // Uncached doing_cron transient fetch 30 30 function _get_cron_lock() { 31 global $ _wp_using_ext_object_cache, $wpdb;31 global $wpdb; 32 32 33 33 $value = 0; 34 if ( $_wp_using_ext_object_cache) {34 if ( wp_using_ext_object_cache() ) { 35 35 // Skip local cache and force refetch of doing_cron transient in case 36 36 // another processs updated the cache 37 37 $value = wp_cache_get( 'doing_cron', 'transient', true );