From 5f1af068d7369bd45aef63b3268a8ec25cf417a4 Mon Sep 17 00:00:00 2001 From: michelvaldrighi Date: Wed, 29 Sep 2004 20:33:05 +0000 Subject: [PATCH] rather ugly fix to prevent the querying of unknown/removed options, feel free to replace it with a better alternative someday git-svn-id: https://develop.svn.wordpress.org/trunk@1723 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/functions.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/wp-includes/functions.php b/wp-includes/functions.php index 79f63f1181..8d13a1e718 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -299,20 +299,33 @@ function url_to_postid($url = '') { /* Options functions */ function get_settings($setting) { - global $wpdb, $cache_settings; + global $wpdb, $cache_settings, $cache_nonexistantoptions; if ( strstr($_SERVER['REQUEST_URI'], 'wp-admin/install.php') || strstr($_SERVER['REQUEST_URI'], 'wp-admin/upgrade.php') ) return false; if ( empty($cache_settings) ) $cache_settings = get_alloptions(); + if ( empty($cache_nonexistantoptions) ) + $cache_nonexistantoptions = array(); + if ('home' == $setting && '' == $cache_settings->home) return $cache_settings->siteurl; if ( isset($cache_settings->$setting) ) : return $cache_settings->$setting; else : + // for these cases when we're asking for an unknown option + if ( isset($cache_nonexistantoptions[$setting]) ) + return false; + $option = $wpdb->get_var("SELECT option_value FROM $wpdb->options WHERE option_name = '$setting'"); + + if (!$option) : + $cache_nonexistantoptions[] = $setting; + return false; + endif; + if (@ $kellogs = unserialize($option) ) return $kellogs; else return $option; endif;