Ticket #2268: cache_option_non_existence.diff
| File cache_option_non_existence.diff, 1.1 KB (added by , 19 years ago) |
|---|
-
wp-includes/functions.php
203 203 function get_option($setting) { 204 204 global $wpdb; 205 205 206 // prevent non-existent options from triggering multiple queries 207 if ( true === wp_cache_get($setting, 'notoptions') ) 208 return false; 209 206 210 $value = wp_cache_get($setting, 'options'); 207 211 208 212 if ( false === $value ) { … … 215 219 if( is_object( $row) ) { // Has to be get_row instead of get_var because of funkiness with 0, false, null values 216 220 $value = $row->option_value; 217 221 wp_cache_set($setting, $value, 'options'); 218 } else { 222 } else { // option does not exist, so we must cache its non-existence 223 wp_cache_set($setting, true, 'notoptions'); 219 224 return false; 220 225 } 221 226 } … … 274 279 return true; 275 280 } 276 281 282 if ( true === wp_cache_get($option_name, 'notoptions') ) 283 wp_cache_delete($option_name, 'notoptions'); 284 277 285 $_newvalue = $newvalue; 278 286 $newvalue = maybe_serialize($newvalue); 279 287