WordPress.org

Make WordPress Core

Ticket #20316: 20316.patch

File 20316.patch, 3.4 KB (added by SergeyBiryukov, 2 years ago)
  • wp-admin/includes/upgrade.php

     
    370370        upgrade_all(); 
    371371        if ( is_multisite() && is_main_site() ) 
    372372                upgrade_network(); 
     373        _clear_transients( 'all' ); 
    373374        wp_cache_flush(); 
    374375 
    375376        if ( is_multisite() ) { 
  • wp-includes/functions.php

     
    33143314function wp_scheduled_delete() { 
    33153315        global $wpdb; 
    33163316 
    3317         $delete_timestamp = time() - (60*60*24*EMPTY_TRASH_DAYS); 
     3317        $delete_timestamp = time() - ( 60 * 60 * 24 * EMPTY_TRASH_DAYS ); 
    33183318 
    3319         $posts_to_delete = $wpdb->get_results($wpdb->prepare("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_wp_trash_meta_time' AND meta_value < '%d'", $delete_timestamp), ARRAY_A); 
     3319        $posts_to_delete = $wpdb->get_results( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_wp_trash_meta_time' AND meta_value < '%d'", $delete_timestamp ), ARRAY_A ); 
    33203320 
    33213321        foreach ( (array) $posts_to_delete as $post ) { 
    33223322                $post_id = (int) $post['post_id']; 
     
    33333333                } 
    33343334        } 
    33353335 
    3336         $comments_to_delete = $wpdb->get_results($wpdb->prepare("SELECT comment_id FROM $wpdb->commentmeta WHERE meta_key = '_wp_trash_meta_time' AND meta_value < '%d'", $delete_timestamp), ARRAY_A); 
     3336        $comments_to_delete = $wpdb->get_results( $wpdb->prepare( "SELECT comment_id FROM $wpdb->commentmeta WHERE meta_key = '_wp_trash_meta_time' AND meta_value < '%d'", $delete_timestamp ), ARRAY_A ); 
    33373337 
    33383338        foreach ( (array) $comments_to_delete as $comment ) { 
    33393339                $comment_id = (int) $comment['comment_id']; 
     
    33493349                        wp_delete_comment($comment_id); 
    33503350                } 
    33513351        } 
     3352 
     3353        _clear_transients(); 
    33523354} 
    33533355 
    33543356/** 
     
    36933695        } 
    36943696} 
    36953697 
     3698/** 
     3699 * Clear transients on a scheduled cleanup or on DB upgrade. 
     3700 * 
     3701 * @since 3.4.0 
     3702 * @access private 
     3703 * 
     3704 * @param string $mode Either 'expired' or 'all'. 
     3705 */ 
     3706function _clear_transients( $mode = 'expired' ) { 
     3707        global $wpdb, $_wp_using_ext_object_cache; 
     3708 
     3709        if ( $_wp_using_ext_object_cache ) 
     3710                return; 
     3711 
     3712        if ( 'expired' == $mode ) 
     3713                $where = "( option_name LIKE '\_transient_timeout%' OR option_name LIKE '\_site_transient_timeout%' ) AND option_value < UNIX_TIMESTAMP()"; 
     3714        else 
     3715                $where = "( option_name LIKE '\_transient%' OR option_name LIKE '\_site_transient%' ) AND option_name NOT LIKE '\_%transient_timeout%'"; 
     3716 
     3717        $transients = $wpdb->get_col( "SELECT option_name FROM $wpdb->options WHERE $where" ); 
     3718 
     3719        foreach ( (array) $transients as $transient ) { 
     3720                if ( false !== strpos( $transient, '_site_transient_' ) ) 
     3721                        delete_site_transient( str_replace( array( '_site_transient_timeout_', '_site_transient_' ), '', $transient ) ); 
     3722                else 
     3723                        delete_transient( str_replace( array( '_transient_timeout_', '_transient_' ), '', $transient ) ); 
     3724        } 
     3725 
     3726        if ( is_multisite() ) { 
     3727                if ( 'expired' == $mode ) 
     3728                        $where = "meta_key LIKE '\_site_transient_timeout%' AND meta_value < UNIX_TIMESTAMP()"; 
     3729                else 
     3730                        $where = "meta_key LIKE '\_site_transient%' AND meta_key NOT LIKE '\_%transient_timeout%'"; 
     3731 
     3732                $site_transients = $wpdb->get_col( "SELECT meta_key FROM $wpdb->sitemeta WHERE $where" ); 
     3733 
     3734                foreach ( (array) $site_transients as $transient ) 
     3735                        delete_site_transient( str_replace( array( '_site_transient_timeout_', '_site_transient_' ), '', $transient ) ); 
     3736        } 
     3737} 
     3738