From a60b801d5d3467dd9ec222c25fa3f85ce9601cd9 Mon Sep 17 00:00:00 2001 From: nacin Date: Thu, 18 Feb 2010 23:41:50 +0000 Subject: [PATCH] Bail early for favicon.ico requests so we don't load WP twice. Props azaozz, sivel. Fixes #3426 git-svn-id: http://svn.automattic.com/wordpress/trunk@13205 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/load.php | 14 ++++++++++++++ wp-settings.php | 3 +++ 2 files changed, 17 insertions(+) diff --git a/wp-includes/load.php b/wp-includes/load.php index e18fd2345b..fe707411f7 100644 --- a/wp-includes/load.php +++ b/wp-includes/load.php @@ -104,6 +104,20 @@ function wp_check_php_mysql_versions() { die( /*WP_I18N_OLD_MYSQL*/'Your PHP installation appears to be missing the MySQL extension which is required by WordPress.'/*/WP_I18N_OLD_MYSQL*/ ); } +/** + * Don't load all of WordPress when handling a favicon.ico request. + * Instead, send the headers for a zero-length favicon and bail. + * + * @since 3.0.0 + */ +function wp_favicon_request() { + if ( '/favicon.ico' == $_SERVER['REQUEST_URI'] ) { + header('Content-Type: image/vnd.microsoft.icon'); + header('Content-Length: 0'); + exit; + } +} + /** * Dies with a maintenance message when conditions are met. * diff --git a/wp-settings.php b/wp-settings.php index 3ac778abe1..71b999eb59 100644 --- a/wp-settings.php +++ b/wp-settings.php @@ -43,6 +43,9 @@ wp_fix_server_vars(); // Check for the required PHP version and for the MySQL extension or a database drop-in. wp_check_php_mysql_versions(); +// Check if we have recieved a request due to missing favicon.ico +wp_favicon_request(); + // Check if we're in maintenance mode. wp_maintenance();