Make WordPress Core

Ticket #41699: 41699.3.diff

File 41699.3.diff, 12.3 KB (added by dd32, 8 years ago)
  • src/wp-admin/admin.php

    if ( get_option('db_upgraded') ) { 
    7575                        do_action( 'after_mu_upgrade', $response );
    7676                        unset($response);
    7777                }
    7878                unset($c);
    7979        }
    8080}
    8181
    8282require_once(ABSPATH . 'wp-admin/includes/admin.php');
    8383
    8484auth_redirect();
    8585
    8686// Schedule trash collection
    8787if ( ! wp_next_scheduled( 'wp_scheduled_delete' ) && ! wp_installing() )
    8888        wp_schedule_event(time(), 'daily', 'wp_scheduled_delete');
    8989
     90// Schedule Transient cleanup
     91if ( ! wp_next_scheduled( 'delete_expired_transients' ) && ! wp_installing() )
     92        wp_schedule_event( time(), 'daily', 'delete_expired_transients' );
     93
    9094set_screen_options();
    9195
    9296$date_format = __( 'F j, Y' );
    9397$time_format = __( 'g:i a' );
    9498
    9599wp_enqueue_script( 'common' );
    96100
    97 
    98 
    99 
    100101/**
    101102 * $pagenow is set in vars.php
    102103 * $wp_importers is sometimes set in wp-admin/includes/import.php
    103104 * The remaining variables are imported as globals elsewhere, declared as globals here
    104105 *
    105106 * @global string $pagenow
    106107 * @global array  $wp_importers
    107108 * @global string $hook_suffix
    108109 * @global string $plugin_page
    109110 * @global string $typenow
    110111 * @global string $taxnow
    111112 */
    112113global $pagenow, $wp_importers, $hook_suffix, $plugin_page, $typenow, $taxnow;
    113114
    114115$page_hook = null;
  • src/wp-admin/includes/schema.php

    function populate_options() { 
    572572                'links_recently_updated_time', 'links_recently_updated_prepend', 'links_recently_updated_append',
    573573                'weblogs_cacheminutes', 'comment_allowed_tags', 'search_engine_friendly_urls', 'default_geourl_lat',
    574574                'default_geourl_lon', 'use_default_geourl', 'weblogs_xml_url', 'new_users_can_blog', '_wpnonce',
    575575                '_wp_http_referer', 'Update', 'action', 'rich_editing', 'autosave_interval', 'deactivated_plugins',
    576576                'can_compress_scripts', 'page_uris', 'update_core', 'update_plugins', 'update_themes', 'doing_cron',
    577577                'random_seed', 'rss_excerpt_length', 'secret', 'use_linksupdate', 'default_comment_status_page',
    578578                'wporg_popular_tags', 'what_to_show', 'rss_language', 'language', 'enable_xmlrpc', 'enable_app',
    579579                'embed_autourls', 'default_post_edit_rows', 'gzipcompression', 'advanced_edit'
    580580        );
    581581        foreach ( $unusedoptions as $option )
    582582                delete_option($option);
    583583
    584584        // Delete obsolete magpie stuff.
    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
    610591/**
    611592 * Execute WordPress role creation for the various WordPress versions.
    612593 *
    613594 * @since 2.0.0
    614595 */
    615596function populate_roles() {
    616597        populate_roles_160();
    617598        populate_roles_210();
    618599        populate_roles_230();
    619600        populate_roles_250();
    620601        populate_roles_260();
    621602        populate_roles_270();
    622603        populate_roles_280();
  • src/wp-admin/includes/upgrade.php

    function upgrade_460() { 
    17341734                }
    17351735        }
    17361736}
    17371737
    17381738/**
    17391739 * Executes network-level upgrade routines.
    17401740 *
    17411741 * @since 3.0.0
    17421742 *
    17431743 * @global int   $wp_current_db_version
    17441744 * @global wpdb  $wpdb
    17451745 */
    17461746function upgrade_network() {
    17471747        global $wp_current_db_version, $wpdb;
    17481748
    1749         // Always.
    1750         if ( is_main_network() ) {
    1751                 /*
    1752                  * Deletes all expired transients. The multi-table delete syntax is used
    1753                  * to delete the transient record from table a, and the corresponding
    1754                  * transient_timeout record from table b.
    1755                  */
    1756                 $time = time();
    1757                 $sql = "DELETE a, b FROM $wpdb->sitemeta a, $wpdb->sitemeta b
    1758                         WHERE a.meta_key LIKE %s
    1759                         AND a.meta_key NOT LIKE %s
    1760                         AND b.meta_key = CONCAT( '_site_transient_timeout_', SUBSTRING( a.meta_key, 17 ) )
    1761                         AND b.meta_value < %d";
    1762                 $wpdb->query( $wpdb->prepare( $sql, $wpdb->esc_like( '_site_transient_' ) . '%', $wpdb->esc_like ( '_site_transient_timeout_' ) . '%', $time ) );
    1763         }
     1749        // Always clear expired transients
     1750        delete_expired_transients( true );
    17641751
    17651752        // 2.8.
    17661753        if ( $wp_current_db_version < 11549 ) {
    17671754                $wpmu_sitewide_plugins = get_site_option( 'wpmu_sitewide_plugins' );
    17681755                $active_sitewide_plugins = get_site_option( 'active_sitewide_plugins' );
    17691756                if ( $wpmu_sitewide_plugins ) {
    17701757                        if ( !$active_sitewide_plugins )
    17711758                                $sitewide_plugins = (array) $wpmu_sitewide_plugins;
    17721759                        else
    17731760                                $sitewide_plugins = array_merge( (array) $active_sitewide_plugins, (array) $wpmu_sitewide_plugins );
    17741761
    17751762                        update_site_option( 'active_sitewide_plugins', $sitewide_plugins );
    17761763                }
    17771764                delete_site_option( 'wpmu_sitewide_plugins' );
    17781765                delete_site_option( 'deactivated_sitewide_plugins' );
  • src/wp-includes/default-filters.php

    add_action( 'sanitize_comment_cookies',  
    305305add_action( 'admin_print_scripts',        'print_emoji_detection_script'                   );
    306306add_action( 'admin_print_scripts',        'print_head_scripts',                      20    );
    307307add_action( 'admin_print_footer_scripts', '_wp_footer_scripts'                             );
    308308add_action( 'admin_print_styles',         'print_emoji_styles'                             );
    309309add_action( 'admin_print_styles',         'print_admin_styles',                      20    );
    310310add_action( 'init',                       'smilies_init',                             5    );
    311311add_action( 'plugins_loaded',             'wp_maybe_load_widgets',                    0    );
    312312add_action( 'plugins_loaded',             'wp_maybe_load_embeds',                     0    );
    313313add_action( 'shutdown',                   'wp_ob_end_flush_all',                      1    );
    314314// Create a revision whenever a post is updated.
    315315add_action( 'post_updated',               'wp_save_post_revision',                   10, 1 );
    316316add_action( 'publish_post',               '_publish_post_hook',                       5, 1 );
    317317add_action( 'transition_post_status',     '_transition_post_status',                  5, 3 );
    318318add_action( 'transition_post_status',     '_update_term_count_on_transition_post_status', 10, 3 );
    319319add_action( 'comment_form',               'wp_comment_form_unfiltered_html_nonce'          );
    320 add_action( 'wp_scheduled_delete',        'wp_scheduled_delete'                            );
    321 add_action( 'wp_scheduled_auto_draft_delete', 'wp_delete_auto_drafts'                      );
    322320add_action( 'admin_init',                 'send_frame_options_header',               10, 0 );
    323 add_action( 'importer_scheduled_cleanup', 'wp_delete_attachment'                           );
    324 add_action( 'upgrader_scheduled_cleanup', 'wp_delete_attachment'                           );
    325321add_action( 'try_gutenberg_panel',        'wp_try_gutenberg_panel'                         );
    326322add_action( 'welcome_panel',              'wp_welcome_panel'                               );
    327323
     324// Cron tasks
     325add_action( 'wp_scheduled_delete',            'wp_scheduled_delete'       );
     326add_action( 'wp_scheduled_auto_draft_delete', 'wp_delete_auto_drafts'     );
     327add_action( 'importer_scheduled_cleanup',     'wp_delete_attachment'      );
     328add_action( 'upgrader_scheduled_cleanup',     'wp_delete_attachment'      );
     329add_action( 'delete_expired_transients',      'delete_expired_transients' );
     330
    328331// Navigation menu actions
    329332add_action( 'delete_post',                '_wp_delete_post_menu_item'         );
    330333add_action( 'delete_term',                '_wp_delete_tax_menu_item',   10, 3 );
    331334add_action( 'transition_post_status',     '_wp_auto_add_pages_to_menu', 10, 3 );
    332335add_action( 'delete_post',                '_wp_delete_customize_changeset_dependent_auto_drafts' );
    333336
    334337// Post Thumbnail CSS class filtering
    335338add_action( 'begin_fetch_post_thumbnail_html', '_wp_post_thumbnail_class_filter_add'    );
    336339add_action( 'end_fetch_post_thumbnail_html',   '_wp_post_thumbnail_class_filter_remove' );
    337340
    338341// Redirect Old Slugs
    339342add_action( 'template_redirect',  'wp_old_slug_redirect'              );
    340343add_action( 'post_updated',       'wp_check_for_changed_slugs', 12, 3 );
    341344add_action( 'attachment_updated', 'wp_check_for_changed_slugs', 12, 3 );
    342345
  • src/wp-includes/option.php

    function set_transient( $transient, $val 
    805805                 * Fires after the value for a transient has been set.
    806806                 *
    807807                 * @since 3.0.0
    808808                 * @since 3.6.0 The `$value` and `$expiration` parameters were added.
    809809                 *
    810810                 * @param string $transient  The name of the transient.
    811811                 * @param mixed  $value      Transient value.
    812812                 * @param int    $expiration Time until expiration in seconds.
    813813                 */
    814814                do_action( 'setted_transient', $transient, $value, $expiration );
    815815        }
    816816        return $result;
    817817}
    818818
    819819/**
     820 * Deletes all expired transients.
     821 *
     822 * The multi-table delete syntax is used to delete the transient record
     823 * from table a, and the corresponding transient_timeout record from table b.                           +
     824 *
     825 * @since 4.9.0
     826 *
     827 * @param bool $force_db Optional. Force cleanup to run against the database even when an external object cache is used.
     828 */
     829function delete_expired_transients( $force_db = false) {
     830        global $wpdb;
     831
     832        if ( ! $force_db && wp_using_ext_object_cache() ) {
     833                return;
     834        }
     835
     836        $wpdb->query( $wpdb->prepare(
     837                "DELETE a, b FROM {$wpdb->options} a, {$wpdb->options} b
     838                        WHERE a.option_name LIKE %s
     839                        AND a.option_name NOT LIKE %s
     840                        AND b.option_name = CONCAT( '_transient_timeout_', SUBSTRING( a.option_name, 12 ) )
     841                        AND b.option_value < %d",
     842                $wpdb->esc_like( '_transient_' ) . '%',
     843                $wpdb->esc_like( '_transient_timeout_' ) . '%',
     844                time()
     845        ) );
     846
     847        if ( ! is_multisite() ) {
     848                // non-Multisite stores site transients in the options table.
     849                $wpdb->query( $wpdb->prepare(
     850                        "DELETE a, b FROM {$wpdb->options} a, {$wpdb->options} b
     851                                WHERE a.option_name LIKE %s
     852                                AND a.option_name NOT LIKE %s
     853                                AND b.option_name = CONCAT( '_site_transient_timeout_', SUBSTRING( a.option_name, 17 ) )
     854                                AND b.option_value < %d",
     855                        $wpdb->esc_like( '_site_transient_' ) . '%',
     856                        $wpdb->esc_like( '_site_transient_timeout_' ) . '%',
     857                        time()
     858                ) );
     859        } elseif ( is_multisite() && is_main_site() && is_main_network() ) {
     860                // Multisite stores site transients in the sitemeta table.
     861                $wpdb->query( $wpdb->prepare(
     862                        "DELETE a, b FROM {$wpdb->sitemeta} a, {$wpdb->sitemeta} b
     863                                WHERE a.meta_key LIKE %s
     864                                AND a.meta_key NOT LIKE %s
     865                                AND b.meta_key = CONCAT( '_site_transient_timeout_', SUBSTRING( a.meta_key, 17 ) )
     866                                AND b.meta_value < %d",
     867                        $wpdb->esc_like( '_site_transient_' ) . '%',
     868                        $wpdb->esc_like( '_site_transient_timeout_' ) . '%',
     869                        time()
     870                ) );
     871        }
     872}
     873
     874/**
    820875 * Saves and restores user interface settings stored in a cookie.
    821876 *
    822877 * Checks if the current user-settings cookie is updated and stores it. When no
    823878 * cookie exists (different browser used), adds the last saved cookie restoring
    824879 * the settings.
    825880 *
    826881 * @since 2.7.0
    827882 */
    828883function wp_user_settings() {
    829884
    830885        if ( ! is_admin() || wp_doing_ajax() ) {
    831886                return;
    832887        }
    833888
    834889        if ( ! $user_id = get_current_user_id() ) {