Make WordPress Core

Ticket #47398: 47398.3.diff

File 47398.3.diff, 11.0 KB (added by SergeyBiryukov, 5 years ago)
  • src/wp-includes/canonical.php

     
    1919 *
    2020 * Prevents redirection for feeds, trackbacks, searches, and
    2121 * admin URLs. Does not redirect on non-pretty-permalink-supporting IIS 7+,
    22  * page/post previews, WP admin, Trackbacks, robots.txt, searches, or on POST
    23  * requests.
     22 * page/post previews, WP admin, Trackbacks, robots.txt, favicon.ico, searches,
     23 * or on POST requests.
    2424 *
    2525 * Will also attempt to find the correct link when a user enters a URL that does
    2626 * not exist based on exact WordPress query. Will instead try to parse the URL
     
    5656                }
    5757        }
    5858
    59         if ( is_trackback() || is_search() || is_admin() || is_preview() || is_robots() || ( $is_IIS && ! iis7_supports_permalinks() ) ) {
     59        if ( is_trackback() || is_search() || is_admin() || is_preview() || is_robots() || is_favicon() || ( $is_IIS && ! iis7_supports_permalinks() ) ) {
    6060                return;
    6161        }
    6262
  • src/wp-includes/class-wp-query.php

     
    391391        public $is_robots = false;
    392392
    393393        /**
     394         * Signifies whether the current query is for the favicon.ico file.
     395         *
     396         * @since 5.3.0
     397         * @var bool
     398         */
     399        public $is_favicon = false;
     400
     401        /**
    394402         * Signifies whether the current query is for the page_for_posts page.
    395403         *
    396404         * Basically, the homepage if the option isn't set for the static homepage.
     
    478486                $this->is_attachment        = false;
    479487                $this->is_singular          = false;
    480488                $this->is_robots            = false;
     489                $this->is_favicon           = false;
    481490                $this->is_posts_page        = false;
    482491                $this->is_post_type_archive = false;
    483492        }
     
    742751
    743752                if ( ! empty( $qv['robots'] ) ) {
    744753                        $this->is_robots = true;
     754                } elseif ( ! empty( $qv['favicon'] ) ) {
     755                        $this->is_favicon = true;
    745756                }
    746757
    747758                if ( ! is_scalar( $qv['p'] ) || $qv['p'] < 0 ) {
     
    955966                        $this->is_comment_feed = true;
    956967                }
    957968
    958                 if ( ! ( $this->is_singular || $this->is_archive || $this->is_search || $this->is_feed || ( defined( 'REST_REQUEST' ) && REST_REQUEST ) || $this->is_trackback || $this->is_404 || $this->is_admin || $this->is_robots ) ) {
     969                if ( ! ( $this->is_singular || $this->is_archive || $this->is_search || $this->is_feed
     970                                || ( defined( 'REST_REQUEST' ) && REST_REQUEST )
     971                                || $this->is_trackback || $this->is_404 || $this->is_admin || $this->is_robots || $this->is_favicon ) ) {
    959972                        $this->is_home = true;
    960973                }
    961974
     
    39984011        }
    39994012
    40004013        /**
    4001          * Is the query for the robots file?
     4014         * Is the query for the robots.txt file?
    40024015         *
    40034016         * @since 3.1.0
    40044017         *
     
    40094022        }
    40104023
    40114024        /**
     4025         * Is the query for the favicon.ico file?
     4026         *
     4027         * @since 5.2.0
     4028         *
     4029         * @return bool
     4030         */
     4031        public function is_favicon() {
     4032                return (bool) $this->is_favicon;
     4033        }
     4034
     4035        /**
    40124036         * Is the query for a search?
    40134037         *
    40144038         * @since 3.1.0
  • src/wp-includes/class-wp-rewrite.php

     
    12591259                        return $rewrite;
    12601260                }
    12611261
    1262                 // robots.txt -only if installed at the root
     1262                // robots.txt -- only if installed at the root
    12631263                $home_path      = parse_url( home_url() );
    12641264                $robots_rewrite = ( empty( $home_path['path'] ) || '/' == $home_path['path'] ) ? array( 'robots\.txt$' => $this->index . '?robots=1' ) : array();
    12651265
     1266                // favicon.ico -- only if installed at the root
     1267                $favicon_rewrite = ( empty( $home_path['path'] ) || '/' == $home_path['path'] ) ? array( 'favicon\.ico$' => $this->index . '?favicon=1' ) : array();
     1268
    12661269                // Old feed and service files.
    12671270                $deprecated_files = array(
    12681271                        '.*wp-(atom|rdf|rss|rss2|feed|commentsrss2)\.php$' => $this->index . '?feed=old',
     
    14191422
    14201423                // Put them together.
    14211424                if ( $this->use_verbose_page_rules ) {
    1422                         $this->rules = array_merge( $this->extra_rules_top, $robots_rewrite, $deprecated_files, $registration_pages, $root_rewrite, $comments_rewrite, $search_rewrite, $author_rewrite, $date_rewrite, $page_rewrite, $post_rewrite, $this->extra_rules );
     1425                        $this->rules = array_merge( $this->extra_rules_top, $robots_rewrite, $favicon_rewrite, $deprecated_files, $registration_pages, $root_rewrite, $comments_rewrite, $search_rewrite, $author_rewrite, $date_rewrite, $page_rewrite, $post_rewrite, $this->extra_rules );
    14231426                } else {
    1424                         $this->rules = array_merge( $this->extra_rules_top, $robots_rewrite, $deprecated_files, $registration_pages, $root_rewrite, $comments_rewrite, $search_rewrite, $author_rewrite, $date_rewrite, $post_rewrite, $page_rewrite, $this->extra_rules );
     1427                        $this->rules = array_merge( $this->extra_rules_top, $robots_rewrite, $favicon_rewrite, $deprecated_files, $registration_pages, $root_rewrite, $comments_rewrite, $search_rewrite, $author_rewrite, $date_rewrite, $post_rewrite, $page_rewrite, $this->extra_rules );
    14251428                }
    14261429
    14271430                /**
  • src/wp-includes/class-wp.php

     
    1414         * @since 2.0.0
    1515         * @var string[]
    1616         */
    17         public $public_query_vars = array( 'm', 'p', 'posts', 'w', 'cat', 'withcomments', 'withoutcomments', 's', 'search', 'exact', 'sentence', 'calendar', 'page', 'paged', 'more', 'tb', 'pb', 'author', 'order', 'orderby', 'year', 'monthnum', 'day', 'hour', 'minute', 'second', 'name', 'category_name', 'tag', 'feed', 'author_name', 'static', 'pagename', 'page_id', 'error', 'attachment', 'attachment_id', 'subpost', 'subpost_id', 'preview', 'robots', 'taxonomy', 'term', 'cpage', 'post_type', 'embed' );
     17        public $public_query_vars = array( 'm', 'p', 'posts', 'w', 'cat', 'withcomments', 'withoutcomments', 's', 'search', 'exact', 'sentence', 'calendar', 'page', 'paged', 'more', 'tb', 'pb', 'author', 'order', 'orderby', 'year', 'monthnum', 'day', 'hour', 'minute', 'second', 'name', 'category_name', 'tag', 'feed', 'author_name', 'static', 'pagename', 'page_id', 'error', 'attachment', 'attachment_id', 'subpost', 'subpost_id', 'preview', 'robots', 'favicon', 'taxonomy', 'term', 'cpage', 'post_type', 'embed' );
    1818
    1919        /**
    2020         * Private query variables.
     
    662662                        return;
    663663                }
    664664
    665                 // Never 404 for the admin, robots, or if we found posts.
    666                 if ( is_admin() || is_robots() || $wp_query->posts ) {
     665                // Never 404 for the admin, robots, favicon, or if we found posts.
     666                if ( is_admin() || is_robots() || is_favicon() || $wp_query->posts ) {
    667667
    668668                        $success = true;
    669669                        if ( is_singular() ) {
  • src/wp-includes/default-filters.php

     
    339339add_action( 'do_feed_atom', 'do_feed_atom', 10, 1 );
    340340add_action( 'do_pings', 'do_all_pings', 10, 1 );
    341341add_action( 'do_robots', 'do_robots' );
     342add_action( 'do_favicon', 'do_favicon' );
    342343add_action( 'set_comment_cookies', 'wp_set_comment_cookies', 10, 3 );
    343344add_action( 'sanitize_comment_cookies', 'sanitize_comment_cookies' );
    344345add_action( 'admin_print_scripts', 'print_emoji_detection_script' );
  • src/wp-includes/functions.php

     
    14971497}
    14981498
    14991499/**
     1500 * Display the favicon.ico file content.
     1501 *
     1502 * @since 5.3.0
     1503 */
     1504function do_favicon() {
     1505        /**
     1506         * Fires when serving the favicon.ico file.
     1507         *
     1508         * @since 5.3.0
     1509         */
     1510        do_action( 'do_faviconico' );
     1511
     1512        if ( has_site_icon() ) {
     1513                $site_icon_id = get_option( 'site_icon' );
     1514                $site_icon    = wp_get_attachment_image_src( $site_icon_id, array( 32, 32 ) );
     1515                $site_icon    = $site_icon[0];
     1516        } else {
     1517                $site_icon = ABSPATH . 'wp-admin/images/w-logo-blue.png';
     1518        }
     1519
     1520        $filetype = wp_check_filetype( $site_icon );
     1521        if ( $filetype['type'] ) {
     1522                $mime_type = $filetype['type'];
     1523        } else {
     1524                $mime_type = 'image/x-icon';
     1525        }
     1526
     1527        header( "Content-Type: $mime_type" );
     1528        readfile( $site_icon );
     1529        exit;
     1530}
     1531
     1532/**
    15001533 * Determines whether WordPress is already installed.
    15011534 *
    15021535 * The cache will be checked first. If you have a cache plugin, which saves
  • src/wp-includes/load.php

     
    162162 * Instead, send the headers for a zero-length favicon and bail.
    163163 *
    164164 * @since 3.0.0
     165 * @deprecated 5.3.0 Deprecated in favor of do_favicon().
    165166 */
    166167function wp_favicon_request() {
    167168        if ( '/favicon.ico' == $_SERVER['REQUEST_URI'] ) {
  • src/wp-includes/query.php

     
    623623}
    624624
    625625/**
    626  * Is the query for the robots file?
     626 * Is the query for the robots.txt file?
    627627 *
    628628 * @since 2.1.0
    629629 *
     
    643643}
    644644
    645645/**
     646 * Is the query for the favicon.ico file?
     647 *
     648 * @since 5.3.0
     649 *
     650 * @global WP_Query $wp_query Global WP_Query instance.
     651 *
     652 * @return bool
     653 */
     654function is_favicon() {
     655        global $wp_query;
     656
     657        if ( ! isset( $wp_query ) ) {
     658                _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' );
     659                return false;
     660        }
     661
     662        return $wp_query->is_favicon();
     663}
     664
     665/**
    646666 * Determines whether the query is for a search.
    647667 *
    648668 * For more information on this and similar theme functions, check out
  • src/wp-includes/template-loader.php

     
    3636         */
    3737        do_action( 'do_robots' );
    3838        return;
     39elseif ( is_favicon() ) :
     40        /**
     41         * Fired when the template loader determines a favicon.ico request.
     42         *
     43         * @since 5.3.0
     44         */
     45        do_action( 'do_favicon' );
     46        return;
    3947elseif ( is_feed() ) :
    4048        do_feed();
    4149        return;
  • src/wp-includes/version.php

     
    2020 *
    2121 * @global int $wp_db_version
    2222 */
    23 $wp_db_version = 44719;
     23$wp_db_version = 45458;
    2424
    2525/**
    2626 * Holds the TinyMCE version
  • src/wp-settings.php

     
    6767// Standardize $_SERVER variables across setups.
    6868wp_fix_server_vars();
    6969
    70 // Check if we have received a request due to missing favicon.ico
    71 wp_favicon_request();
    72 
    7370// Check if we're in maintenance mode.
    7471wp_maintenance();
    7572