Changeset 41963
- Timestamp:
- 10/21/2017 01:21:24 PM (7 years ago)
- Location:
- trunk/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/schema.php
r41348 r41963 585 585 $wpdb->query("DELETE FROM $wpdb->options WHERE option_name REGEXP '^rss_[0-9a-f]{32}(_ts)?$'"); 586 586 587 /* 588 * Deletes all expired transients. The multi-table delete syntax is used 589 * to delete the transient record from table a, and the corresponding 590 * transient_timeout record from table b. 591 */ 592 $time = time(); 593 $sql = "DELETE a, b FROM $wpdb->options a, $wpdb->options b 594 WHERE a.option_name LIKE %s 595 AND a.option_name NOT LIKE %s 596 AND b.option_name = CONCAT( '_transient_timeout_', SUBSTRING( a.option_name, 12 ) ) 597 AND b.option_value < %d"; 598 $wpdb->query( $wpdb->prepare( $sql, $wpdb->esc_like( '_transient_' ) . '%', $wpdb->esc_like( '_transient_timeout_' ) . '%', $time ) ); 599 600 if ( is_main_site() && is_main_network() ) { 601 $sql = "DELETE a, b FROM $wpdb->options a, $wpdb->options b 602 WHERE a.option_name LIKE %s 603 AND a.option_name NOT LIKE %s 604 AND b.option_name = CONCAT( '_site_transient_timeout_', SUBSTRING( a.option_name, 17 ) ) 605 AND b.option_value < %d"; 606 $wpdb->query( $wpdb->prepare( $sql, $wpdb->esc_like( '_site_transient_' ) . '%', $wpdb->esc_like( '_site_transient_timeout_' ) . '%', $time ) ); 607 } 587 // Clear expired transients 588 delete_expired_transients( true ); 608 589 } 609 590 -
trunk/src/wp-admin/includes/upgrade.php
r41717 r41963 1747 1747 global $wp_current_db_version, $wpdb; 1748 1748 1749 // Always. 1750 if ( is_main_network() ) { 1751 /* 1752 * Deletes all expired transients. The multi-table delete syntax is used 1753 * to delete the transient record from table a, and the corresponding 1754 * transient_timeout record from table b. 1755 */ 1756 $time = time(); 1757 $sql = "DELETE a, b FROM $wpdb->sitemeta a, $wpdb->sitemeta b 1758 WHERE a.meta_key LIKE %s 1759 AND a.meta_key NOT LIKE %s 1760 AND b.meta_key = CONCAT( '_site_transient_timeout_', SUBSTRING( a.meta_key, 17 ) ) 1761 AND b.meta_value < %d"; 1762 $wpdb->query( $wpdb->prepare( $sql, $wpdb->esc_like( '_site_transient_' ) . '%', $wpdb->esc_like ( '_site_transient_timeout_' ) . '%', $time ) ); 1763 } 1749 // Always clear expired transients 1750 delete_expired_transients( true ); 1764 1751 1765 1752 // 2.8. -
trunk/src/wp-includes/default-filters.php
r41895 r41963 318 318 add_action( 'transition_post_status', '_update_term_count_on_transition_post_status', 10, 3 ); 319 319 add_action( 'comment_form', 'wp_comment_form_unfiltered_html_nonce' ); 320 add_action( 'wp_scheduled_delete', 'wp_scheduled_delete' );321 add_action( 'wp_scheduled_auto_draft_delete', 'wp_delete_auto_drafts' );322 320 add_action( 'admin_init', 'send_frame_options_header', 10, 0 ); 323 add_action( 'importer_scheduled_cleanup', 'wp_delete_attachment' );324 add_action( 'upgrader_scheduled_cleanup', 'wp_delete_attachment' );325 321 add_action( 'try_gutenberg_panel', 'wp_try_gutenberg_panel' ); 326 322 add_action( 'welcome_panel', 'wp_welcome_panel' ); 323 324 // Cron tasks 325 add_action( 'wp_scheduled_delete', 'wp_scheduled_delete' ); 326 add_action( 'wp_scheduled_auto_draft_delete', 'wp_delete_auto_drafts' ); 327 add_action( 'importer_scheduled_cleanup', 'wp_delete_attachment' ); 328 add_action( 'upgrader_scheduled_cleanup', 'wp_delete_attachment' ); 329 add_action( 'delete_expired_transients', 'delete_expired_transients' ); 327 330 328 331 // Navigation menu actions -
trunk/src/wp-includes/option.php
r41627 r41963 818 818 819 819 /** 820 * Deletes all expired transients. 821 * 822 * The multi-table delete syntax is used to delete the transient record 823 * from table a, and the corresponding transient_timeout record from table b. + 824 * 825 * @since 4.9.0 826 * 827 * @param bool $force_db Optional. Force cleanup to run against the database even when an external object cache is used. 828 */ 829 function delete_expired_transients( $force_db = false) { 830 global $wpdb; 831 832 if ( ! $force_db && wp_using_ext_object_cache() ) { 833 return; 834 } 835 836 $wpdb->query( $wpdb->prepare( 837 "DELETE a, b FROM {$wpdb->options} a, {$wpdb->options} b 838 WHERE a.option_name LIKE %s 839 AND a.option_name NOT LIKE %s 840 AND b.option_name = CONCAT( '_transient_timeout_', SUBSTRING( a.option_name, 12 ) ) 841 AND b.option_value < %d", 842 $wpdb->esc_like( '_transient_' ) . '%', 843 $wpdb->esc_like( '_transient_timeout_' ) . '%', 844 time() 845 ) ); 846 847 if ( ! is_multisite() ) { 848 // non-Multisite stores site transients in the options table. 849 $wpdb->query( $wpdb->prepare( 850 "DELETE a, b FROM {$wpdb->options} a, {$wpdb->options} b 851 WHERE a.option_name LIKE %s 852 AND a.option_name NOT LIKE %s 853 AND b.option_name = CONCAT( '_site_transient_timeout_', SUBSTRING( a.option_name, 17 ) ) 854 AND b.option_value < %d", 855 $wpdb->esc_like( '_site_transient_' ) . '%', 856 $wpdb->esc_like( '_site_transient_timeout_' ) . '%', 857 time() 858 ) ); 859 } elseif ( is_multisite() && is_main_site() && is_main_network() ) { 860 // Multisite stores site transients in the sitemeta table. 861 $wpdb->query( $wpdb->prepare( 862 "DELETE a, b FROM {$wpdb->sitemeta} a, {$wpdb->sitemeta} b 863 WHERE a.meta_key LIKE %s 864 AND a.meta_key NOT LIKE %s 865 AND b.meta_key = CONCAT( '_site_transient_timeout_', SUBSTRING( a.meta_key, 17 ) ) 866 AND b.meta_value < %d", 867 $wpdb->esc_like( '_site_transient_' ) . '%', 868 $wpdb->esc_like( '_site_transient_timeout_' ) . '%', 869 time() 870 ) ); 871 } 872 } 873 874 /** 820 875 * Saves and restores user interface settings stored in a cookie. 821 876 *
Note: See TracChangeset
for help on using the changeset viewer.