Ticket #9048: 9048.diff
| File 9048.diff, 5.5 KB (added by , 17 years ago) |
|---|
-
wp-includes/functions.php
625 625 } 626 626 627 627 /** 628 * Delete a transient 629 * 630 * @since 2.8.0 631 * @package WordPress 632 * @subpackage Transient 633 * 634 * @param string $transient Transient name. Expected to not be SQL-escaped 635 * @return bool true if successful, false otherwise 636 */ 637 function delete_transient($transient) { 638 global $_wp_using_ext_object_cache, $wpdb; 639 640 if ( $_wp_using_ext_object_cache ) { 641 return wp_cache_delete($transient, 'transient'); 642 } else { 643 $transient = $wpdb->escape($transient); 644 return delete_option($transient); 645 } 646 } 647 648 /** 649 * Get the value of a transient 650 * 651 * If the transient does not exist or does not have a value, then the return value 652 * will be false. 653 * 654 * @since 2.8.0 655 * @package WordPress 656 * @subpackage Transient 657 * 658 * @param string $transient Transient name. Expected to not be SQL-escaped 659 * @return mixed Value of transient 660 */ 661 function get_transient($transient) { 662 global $_wp_using_ext_object_cache, $wpdb; 663 664 if ( $_wp_using_ext_object_cache ) { 665 return wp_cache_get($transient, 'transient'); 666 } else { 667 $transient = $wpdb->escape($transient); 668 return get_option($transient); 669 } 670 } 671 672 /** 673 * Set/update the value of a transient 674 * 675 * You do not need to serialize values, if the value needs to be serialize, then 676 * it will be serialized before it is set. 677 * 678 * @since 2.8.0 679 * @package WordPress 680 * @subpackage Transient 681 * 682 * @param string $transient Transient name. Expected to not be SQL-escaped 683 * @param mixed $value Transient value. 684 * @return bool False if value was not set and true if value was set. 685 */ 686 function set_transient($transient, $value) { 687 global $_wp_using_ext_object_cache, $wpdb; 688 689 if ( $_wp_using_ext_object_cache ) { 690 return wp_cache_set($transient, $value, 'transient'); 691 } else { 692 $safe_transient = $wpdb->escape($transient); 693 if ( false === get_option( $safe_transient ) ) 694 return add_option($transient, $value, '', 'no'); 695 else 696 return update_option($transient, $value); 697 } 698 } 699 700 /** 628 701 * Saves and restores user interface settings stored in a cookie. 629 702 * 630 703 * Checks if the current user-settings cookie is updated and stores it. When no -
wp-includes/rewrite.php
1596 1596 * @return array Rewrite rules. 1597 1597 */ 1598 1598 function wp_rewrite_rules() { 1599 $this->rules = get_ option('rewrite_rules');1599 $this->rules = get_transient('rewrite_rules'); 1600 1600 if ( empty($this->rules) ) { 1601 1601 $this->matches = 'matches'; 1602 1602 $this->rewrite_rules(); 1603 update_option('rewrite_rules', $this->rules);1603 set_transient('rewrite_rules', $this->rules); 1604 1604 } 1605 1605 1606 1606 return $this->rules; … … 1783 1783 * @access public 1784 1784 */ 1785 1785 function flush_rules() { 1786 delete_ option('rewrite_rules');1786 delete_transient('rewrite_rules'); 1787 1787 $this->wp_rewrite_rules(); 1788 1788 if ( function_exists('save_mod_rewrite_rules') ) 1789 1789 save_mod_rewrite_rules(); -
wp-includes/rss.php
714 714 $cache_option = 'rss_' . $this->file_name( $url ); 715 715 $cache_timestamp = 'rss_' . $this->file_name( $url ) . '_ts'; 716 716 717 // shouldn't these be using get_option() ? 718 if ( !$wpdb->get_var( $wpdb->prepare( "SELECT option_name FROM $wpdb->options WHERE option_name = %s", $cache_option ) ) ) 719 add_option($cache_option, '', '', 'no'); 720 if ( !$wpdb->get_var( $wpdb->prepare( "SELECT option_name FROM $wpdb->options WHERE option_name = %s", $cache_timestamp ) ) ) 721 add_option($cache_timestamp, '', '', 'no'); 717 set_transient($cache_option, $rss); 718 set_transient($cache_timestamp, time() ); 722 719 723 update_option($cache_option, $rss);724 update_option($cache_timestamp, time() );725 726 720 return $cache_option; 727 721 } 728 722 … … 736 730 $this->ERROR = ""; 737 731 $cache_option = 'rss_' . $this->file_name( $url ); 738 732 739 if ( ! get_option( $cache_option ) ) {733 if ( ! $rss = get_transient( $cache_option ) ) { 740 734 $this->debug( 741 735 "Cache doesn't contain: $url (cache option: $cache_option)" 742 736 ); 743 737 return 0; 744 738 } 745 739 746 $rss = get_option( $cache_option );747 748 740 return $rss; 749 741 } 750 742 … … 760 752 $cache_option = $this->file_name( $url ); 761 753 $cache_timestamp = 'rss_' . $this->file_name( $url ) . '_ts'; 762 754 763 if ( $mtime = get_ option($cache_timestamp) ) {755 if ( $mtime = get_transient($cache_timestamp) ) { 764 756 // find how long ago the file was added to the cache 765 757 // and whether that is longer then MAX_AGE 766 758 $age = time() - $mtime; -
wp-settings.php
257 257 if ( is_wp_error($prefix) ) 258 258 wp_die(/*WP_I18N_BAD_PREFIX*/'<strong>ERROR</strong>: <code>$table_prefix</code> in <code>wp-config.php</code> can only contain numbers, letters, and underscores.'/*/WP_I18N_BAD_PREFIX*/); 259 259 260 if ( file_exists(WP_CONTENT_DIR . '/object-cache.php') ) 260 if ( file_exists(WP_CONTENT_DIR . '/object-cache.php') ) { 261 261 require_once (WP_CONTENT_DIR . '/object-cache.php'); 262 else 262 $_wp_using_ext_object_cache = true; 263 } else { 263 264 require_once (ABSPATH . WPINC . '/cache.php'); 265 $_wp_using_ext_object_cache = false; 266 } 264 267 265 268 wp_cache_init(); 266 269 if ( function_exists('wp_cache_add_global_groups') ) {