Make WordPress Core

Ticket #26402: patch.diff

File patch.diff, 1.8 KB (added by codix, 10 years ago)
  • wp-includes/option.php

    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 ) { 
    238238
    239239        do_action( 'update_option', $option, $old_value, $value );
    240240        $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
    242255                return false;
     256        }
    243257
    244258        $notoptions = wp_cache_get( 'notoptions', 'options' );
    245259        if ( is_array( $notoptions ) && isset( $notoptions[$option] ) ) {
    function update_option( $option, $value ) { 
    260274        do_action( "update_option_{$option}", $old_value, $value );
    261275        do_action( 'updated_option', $option, $old_value, $value );
    262276        return true;
     277
    263278}
    264279
    265280/**
    function update_site_option( $option, $value ) { 
    942957                if ( $result ) {
    943958                        $cache_key = "{$wpdb->siteid}:$option";
    944959                        wp_cache_set( $cache_key, $value, 'site-options' );
     960                } else {
     961                        wp_cache_delete( $cache_key, 'site-options' );
     962                        add_site_option( $option, $value );
    945963                }
    946964        }
    947965