Make WordPress Core


Ignore:
Timestamp:
10/21/2017 01:21:24 PM (8 years ago)
Author:
dd32
Message:

Transients: Clear expired transients from the database in a daily cron task.

Fixes #41699

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/schema.php

    r41348 r41963  
    585585    $wpdb->query("DELETE FROM $wpdb->options WHERE option_name REGEXP '^rss_[0-9a-f]{32}(_ts)?$'");
    586586
    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 );
    608589}
    609590
Note: See TracChangeset for help on using the changeset viewer.