Make WordPress Core

Ticket #20316: 20316.3.diff

File 20316.3.diff, 2.4 KB (added by pento, 10 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         // clear transient data
    550         $wpdb->query( "DELETE FROM $wpdb->options WHERE option_name LIKE '\_transient\_%' OR option_name LIKE '\_site\_transient\_%'" );
     549
     550        // Deletes all non-expiring transients, and expired transients.
     551        // The multi-table delete syntax is used to delete transient record from table a,
     552        // and the corresponding transient_timeout record (if any) from table b.
     553        $time = time();
     554        $wpdb->query("DELETE a, b FROM $wpdb->options a, $wpdb->options b WHERE
     555                a.option_name LIKE '\_transient\_%' AND
     556                a.option_name NOT LIKE '\_transient\_timeout\_%' AND
     557                b.option_name = CONCAT( '_transient_timeout_', SUBSTRING( a.option_name, 12 ) )
     558                AND b.option_value < $time");
     559
     560        if ( is_main_site() && is_main_network() ) {
     561                $wpdb->query("DELETE a, b FROM $wpdb->options a, $wpdb->options b WHERE
     562                        a.option_name LIKE '\_site\_transient\_%' AND
     563                        a.option_name NOT LIKE '\_site\_transient\_timeout\_%' AND
     564                        b.option_name = CONCAT( '_site_transient_timeout_', SUBSTRING( a.option_name, 17 ) )
     565                        AND b.option_value < $time");
     566    }
    551567}
    552568
    553569/**
  • src/wp-admin/includes/upgrade.php

     
    12291229 */
    12301230function upgrade_network() {
    12311231        global $wp_current_db_version, $wpdb;
     1232
     1233        // Always
     1234        if ( is_main_network() ) {
     1235                // Deletes all non-expiring transients, and expired transients.
     1236                // The multi-table delete syntax is used to delete transient record from table a,
     1237                // and the corresponding transient_timeout record (if any) from table b.
     1238                $time = time();
     1239                $wpdb->query("DELETE a, b FROM $wpdb->sitemeta a, $wpdb->sitemeta b WHERE
     1240                        a.meta_key LIKE '\_site\_transient\_%' AND
     1241                        a.meta_key NOT LIKE '\_site\_transient\_timeout\_%' AND
     1242                        b.meta_key = CONCAT( '_site_transient_timeout_', SUBSTRING( a.meta_key, 17 ) )
     1243                        AND b.meta_value < $time");
     1244        }
     1245
    12321246        // 2.8
    12331247        if ( $wp_current_db_version < 11549 ) {
    12341248                $wpmu_sitewide_plugins = get_site_option( 'wpmu_sitewide_plugins' );