Permalink
Browse files

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
  • Loading branch information...
1 parent 54c4ac3 commit a60b801d5d3467dd9ec222c25fa3f85ce9601cd9 nacin committed Feb 18, 2010
Showing with 17 additions and 0 deletions.
  1. +14 −0 wp-includes/load.php
  2. +3 −0 wp-settings.php
View
14 wp-includes/load.php
@@ -105,6 +105,20 @@ function wp_check_php_mysql_versions() {
}
/**
+ * 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.
*
* Checks for a file in the WordPress root directory named ".maintenance".
View
3 wp-settings.php
@@ -43,6 +43,9 @@
// 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();

0 comments on commit a60b801

Please sign in to comment.