mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 22:30:04 +00:00
Transients: Clear expired transients from the database in a daily cron task.
Fixes #41699 git-svn-id: https://develop.svn.wordpress.org/trunk@41963 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -584,27 +584,8 @@ function populate_options() {
|
||||
// Delete obsolete magpie stuff.
|
||||
$wpdb->query("DELETE FROM $wpdb->options WHERE option_name REGEXP '^rss_[0-9a-f]{32}(_ts)?$'");
|
||||
|
||||
/*
|
||||
* Deletes all expired transients. The multi-table delete syntax is used
|
||||
* to delete the transient record from table a, and the corresponding
|
||||
* transient_timeout record from table b.
|
||||
*/
|
||||
$time = time();
|
||||
$sql = "DELETE a, b FROM $wpdb->options a, $wpdb->options b
|
||||
WHERE a.option_name LIKE %s
|
||||
AND a.option_name NOT LIKE %s
|
||||
AND b.option_name = CONCAT( '_transient_timeout_', SUBSTRING( a.option_name, 12 ) )
|
||||
AND b.option_value < %d";
|
||||
$wpdb->query( $wpdb->prepare( $sql, $wpdb->esc_like( '_transient_' ) . '%', $wpdb->esc_like( '_transient_timeout_' ) . '%', $time ) );
|
||||
|
||||
if ( is_main_site() && is_main_network() ) {
|
||||
$sql = "DELETE a, b FROM $wpdb->options a, $wpdb->options b
|
||||
WHERE a.option_name LIKE %s
|
||||
AND a.option_name NOT LIKE %s
|
||||
AND b.option_name = CONCAT( '_site_transient_timeout_', SUBSTRING( a.option_name, 17 ) )
|
||||
AND b.option_value < %d";
|
||||
$wpdb->query( $wpdb->prepare( $sql, $wpdb->esc_like( '_site_transient_' ) . '%', $wpdb->esc_like( '_site_transient_timeout_' ) . '%', $time ) );
|
||||
}
|
||||
// Clear expired transients
|
||||
delete_expired_transients( true );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1746,21 +1746,8 @@ function upgrade_460() {
|
||||
function upgrade_network() {
|
||||
global $wp_current_db_version, $wpdb;
|
||||
|
||||
// Always.
|
||||
if ( is_main_network() ) {
|
||||
/*
|
||||
* Deletes all expired transients. The multi-table delete syntax is used
|
||||
* to delete the transient record from table a, and the corresponding
|
||||
* transient_timeout record from table b.
|
||||
*/
|
||||
$time = time();
|
||||
$sql = "DELETE a, b FROM $wpdb->sitemeta a, $wpdb->sitemeta b
|
||||
WHERE a.meta_key LIKE %s
|
||||
AND a.meta_key NOT LIKE %s
|
||||
AND b.meta_key = CONCAT( '_site_transient_timeout_', SUBSTRING( a.meta_key, 17 ) )
|
||||
AND b.meta_value < %d";
|
||||
$wpdb->query( $wpdb->prepare( $sql, $wpdb->esc_like( '_site_transient_' ) . '%', $wpdb->esc_like ( '_site_transient_timeout_' ) . '%', $time ) );
|
||||
}
|
||||
// Always clear expired transients
|
||||
delete_expired_transients( true );
|
||||
|
||||
// 2.8.
|
||||
if ( $wp_current_db_version < 11549 ) {
|
||||
|
||||
Reference in New Issue
Block a user