Delete expired transients on database upgrades.
Reverts [25416], which had all transients being cleared. This leaves much to be desired, but we don't want a core update to be blamed for breaking a site that incorrectly assumes transients aren't transient. props dartiss, pento. fixes #20316. Built from https://develop.svn.wordpress.org/trunk@25838 git-svn-id: http://core.svn.wordpress.org/trunk@25750 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
5f3e90a112
commit
859da01c4a
|
@ -546,8 +546,24 @@ function populate_options() {
|
|||
|
||||
// delete obsolete magpie stuff
|
||||
$wpdb->query("DELETE FROM $wpdb->options WHERE option_name REGEXP '^rss_[0-9a-f]{32}(_ts)?$'");
|
||||
// clear transient data
|
||||
$wpdb->query( "DELETE FROM $wpdb->options WHERE option_name LIKE '\_transient\_%' OR option_name LIKE '\_site\_transient\_%'" );
|
||||
|
||||
// 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();
|
||||
$wpdb->query("DELETE a, b FROM $wpdb->options a, $wpdb->options b WHERE
|
||||
a.option_name LIKE '\_transient\_%' AND
|
||||
a.option_name NOT LIKE '\_transient\_timeout\_%' AND
|
||||
b.option_name = CONCAT( '_transient_timeout_', SUBSTRING( a.option_name, 12 ) )
|
||||
AND b.option_value < $time");
|
||||
|
||||
if ( is_main_site() && is_main_network() ) {
|
||||
$wpdb->query("DELETE a, b FROM $wpdb->options a, $wpdb->options b WHERE
|
||||
a.option_name LIKE '\_site\_transient\_%' AND
|
||||
a.option_name NOT LIKE '\_site\_transient\_timeout\_%' AND
|
||||
b.option_name = CONCAT( '_site_transient_timeout_', SUBSTRING( a.option_name, 17 ) )
|
||||
AND b.option_value < $time");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1229,6 +1229,20 @@ function upgrade_370() {
|
|||
*/
|
||||
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();
|
||||
$wpdb->query("DELETE a, b FROM $wpdb->sitemeta a, $wpdb->sitemeta b WHERE
|
||||
a.meta_key LIKE '\_site\_transient\_%' AND
|
||||
a.meta_key NOT LIKE '\_site\_transient\_timeout\_%' AND
|
||||
b.meta_key = CONCAT( '_site_transient_timeout_', SUBSTRING( a.meta_key, 17 ) )
|
||||
AND b.meta_value < $time");
|
||||
}
|
||||
|
||||
// 2.8
|
||||
if ( $wp_current_db_version < 11549 ) {
|
||||
$wpmu_sitewide_plugins = get_site_option( 'wpmu_sitewide_plugins' );
|
||||
|
|
Loading…
Reference in New Issue