Changeset 10603 for trunk/wp-includes/functions.php
- Timestamp:
- 02/20/2009 02:23:11 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/functions.php
r10593 r10603 666 666 } else { 667 667 $transient_option = '_transient_' . $wpdb->escape($transient); 668 // If option is not in alloptions, it is not autoloaded and thus has a timeout 669 $alloptions = wp_load_alloptions(); 670 if ( !isset( $alloptions[$transient_option] ) ) { 671 $transient_timeout = '_transient_timeout_' . $wpdb->escape($transient); 672 if ( get_option($transient_timeout) > time() ) { 673 delete_option($transient_option); 674 delete_option($transient_timeout); 675 return false; 676 } 677 } 678 668 679 $value = get_option($transient_option); 669 680 } … … 684 695 * @param string $transient Transient name. Expected to not be SQL-escaped 685 696 * @param mixed $value Transient value. 697 * @param int $expiration Time until expiration in seconds, default 0 686 698 * @return bool False if value was not set and true if value was set. 687 699 */ 688 function set_transient($transient, $value ) {700 function set_transient($transient, $value, $expiration = 0) { 689 701 global $_wp_using_ext_object_cache, $wpdb; 690 702 691 703 if ( $_wp_using_ext_object_cache ) { 692 return wp_cache_set($transient, $value, 'transient' );704 return wp_cache_set($transient, $value, 'transient', $expiration); 693 705 } else { 706 $transient_timeout = '_transient_timeout_' . $transient; 694 707 $transient = '_transient_' . $transient; 695 708 $safe_transient = $wpdb->escape($transient); 696 if ( false === get_option( $safe_transient ) ) 697 return add_option($transient, $value, '', 'no'); 698 else 709 if ( false === get_option( $safe_transient ) ) { 710 $autoload = 'yes'; 711 if ( 0 != $expiration ) { 712 $autoload = 'no'; 713 add_option($transient_timeout, time() + $expiration, '', 'no'); 714 } 715 return add_option($transient, $value, '', $autoload); 716 } else { 717 if ( 0 != $expiration ) 718 update_option($transient_timeout, time() + $expiration); 699 719 return update_option($transient, $value); 720 } 700 721 } 701 722 }
Note: See TracChangeset
for help on using the changeset viewer.