From 3433930b7a0bb7622d6f6c949cfbeb9c3c8fd0ea Mon Sep 17 00:00:00 2001
From: S H Mohanjith <moha@mohanjith.net>
Date: Wed, 4 Dec 2013 19:41:01 +0200
Subject: [PATCH] If updating the option failed delete from cache and add the
option.
---
wp-includes/option.php | 20 +++++++++++++++++++-
1 file changed, 19 insertions(+), 1 deletion(-)
diff --git a/wp-includes/option.php b/wp-includes/option.php
index 0f35a5f..3f49b5e 100644
a
|
b
|
function update_option( $option, $value ) { |
238 | 238 | |
239 | 239 | do_action( 'update_option', $option, $old_value, $value ); |
240 | 240 | $result = $wpdb->update( $wpdb->options, array( 'option_value' => $serialized_value ), array( 'option_name' => $option ) ); |
241 | | if ( ! $result ) |
| 241 | if ( ! $result ) { |
| 242 | if ( ! defined( 'WP_INSTALLING' ) ) { |
| 243 | $alloptions = wp_load_alloptions(); |
| 244 | if ( isset( $alloptions[$option] ) ) { |
| 245 | unset($alloptions[$option]); |
| 246 | wp_cache_set( 'alloptions', $alloptions, 'options' ); |
| 247 | } |
| 248 | } else if ( !isset( $alloptions[$option] ) ) { |
| 249 | wp_cache_delete( 'alloptions', 'options' ); |
| 250 | } else { |
| 251 | wp_cache_delete( $option, 'options' ); |
| 252 | } |
| 253 | add_option( $option, $newvalue ); |
| 254 | |
242 | 255 | return false; |
| 256 | } |
243 | 257 | |
244 | 258 | $notoptions = wp_cache_get( 'notoptions', 'options' ); |
245 | 259 | if ( is_array( $notoptions ) && isset( $notoptions[$option] ) ) { |
… |
… |
function update_option( $option, $value ) { |
260 | 274 | do_action( "update_option_{$option}", $old_value, $value ); |
261 | 275 | do_action( 'updated_option', $option, $old_value, $value ); |
262 | 276 | return true; |
| 277 | |
263 | 278 | } |
264 | 279 | |
265 | 280 | /** |
… |
… |
function update_site_option( $option, $value ) { |
942 | 957 | if ( $result ) { |
943 | 958 | $cache_key = "{$wpdb->siteid}:$option"; |
944 | 959 | wp_cache_set( $cache_key, $value, 'site-options' ); |
| 960 | } else { |
| 961 | wp_cache_delete( $cache_key, 'site-options' ); |
| 962 | add_site_option( $option, $value ); |
945 | 963 | } |
946 | 964 | } |
947 | 965 | |