Skip to content

Commit e644188

Browse files
Options: Invalidate object cache when update_option() DB write fails
1 parent 9098796 commit e644188

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/wp-includes/option.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -963,6 +963,19 @@ function update_option( $option, $value, $autoload = null ) {
963963

964964
$result = $wpdb->update( $wpdb->options, $update_args, array( 'option_name' => $option ) );
965965
if ( ! $result ) {
966+
if ( ! wp_installing() ) {
967+
$alloptions = wp_load_alloptions( true );
968+
969+
if ( isset( $alloptions[ $option ] ) ) {
970+
unset( $alloptions[ $option ] );
971+
wp_cache_set( 'alloptions', $alloptions, 'options' );
972+
} else {
973+
wp_cache_delete( 'alloptions', 'options' );
974+
}
975+
976+
wp_cache_delete( $option, 'options' );
977+
}
978+
966979
return false;
967980
}
968981

0 commit comments

Comments
 (0)