Make WordPress Core

Ticket #20316: 20316.diff

File 20316.diff, 2.0 KB (added by nacin, 11 years ago)
  • src/wp-admin/includes/schema.php

     
    546546
    547547        // delete obsolete magpie stuff
    548548        $wpdb->query("DELETE FROM $wpdb->options WHERE option_name REGEXP '^rss_[0-9a-f]{32}(_ts)?$'");
     549
    549550        // clear transient data
    550         $wpdb->query( "DELETE FROM $wpdb->options WHERE option_name LIKE '\_transient\_%' OR option_name LIKE '\_site\_transient\_%'" );
     551        $time = time();
     552        $wpdb->query("DELETE a, b FROM $wpdb->options a, $wpdb->options b WHERE
     553                a.option_name LIKE '\_transient\_%' AND
     554                a.option_name NOT LIKE '\_transient\_timeout\_%' AND
     555                b.option_name = CONCAT( '_transient_timeout_', SUBSTRING( a.option_name, 12 ) )
     556                AND b.option_value < $time");
     557
     558        if ( is_main_site() && is_main_network() ) {
     559                $wpdb->query("DELETE a, b FROM $wpdb->options a, $wpdb->options b WHERE
     560                        a.option_name LIKE '\_site\_transient\_%' AND
     561                        a.option_name NOT LIKE '\_site\_transient\_timeout\_%' AND
     562                        b.option_name = CONCAT( '_site_transient_timeout_', SUBSTRING( a.option_name, 17 ) )
     563                        AND b.option_value < $time");
     564    }
    551565}
    552566
    553567/**
  • src/wp-admin/includes/upgrade.php

     
    12151215 */
    12161216function upgrade_network() {
    12171217        global $wp_current_db_version, $wpdb;
     1218
     1219        // Always
     1220        if ( is_main_network() ) {
     1221                $time = time();
     1222                $wpdb->query("DELETE a, b FROM $wpdb->sitemeta a, $wpdb->sitemeta b WHERE
     1223                        a.meta_key LIKE '\_site\_transient\_%' AND
     1224                        a.meta_key NOT LIKE '\_site\_transient\_timeout\_%' AND
     1225                        b.meta_key = CONCAT( '_site_transient_timeout_', SUBSTRING( a.meta_key, 17 ) )
     1226                        AND b.meta_value < $time");
     1227        }
     1228
    12181229        // 2.8
    12191230        if ( $wp_current_db_version < 11549 ) {
    12201231                $wpmu_sitewide_plugins = get_site_option( 'wpmu_sitewide_plugins' );