Ticket #26394: 26394.2.diff
File 26394.2.diff, 2.0 KB (added by , 10 years ago) |
---|
-
src/wp-includes/option.php
224 224 * 225 225 * @param string $option Option name. Expected to not be SQL-escaped. 226 226 * @param mixed $value Option value. Must be serializable if non-scalar. Expected to not be SQL-escaped. 227 * @param string $autoload Autoload by default, while allowing it to be changed. 227 228 * @return bool False if value was not updated and true if value was updated. 228 229 */ 229 function update_option( $option, $value ) {230 function update_option( $option, $value, $autoload = 'yes' ) { 230 231 global $wpdb; 231 232 232 $option = trim( $option);233 if ( empty( $option) )233 $option = trim( $option ); 234 if ( empty( $option ) ) { 234 235 return false; 236 } 235 237 236 238 wp_protect_special_option( $option ); 237 239 238 if ( is_object( $value ) ) 240 if ( is_object( $value ) ) { 239 241 $value = clone $value; 242 } 240 243 241 244 $value = sanitize_option( $option, $value ); 242 245 $old_value = get_option( $option ); … … 265 268 $value = apply_filters( 'pre_update_option', $value, $option, $old_value ); 266 269 267 270 // If the new and old values are the same, no need to update. 268 if ( $value === $old_value ) 271 if ( $value === $old_value ) { 269 272 return false; 273 } 270 274 271 275 /** This filter is documented in wp-includes/option.php */ 272 if ( apply_filters( 'default_option_' . $option, false ) === $old_value ) 273 return add_option( $option, $value ); 276 if ( apply_filters( 'default_option_' . $option, false ) === $old_value ) { 277 return add_option( $option, $value, $autoload ); 278 } 274 279 275 280 $serialized_value = maybe_serialize( $value ); 276 281 … … 286 291 do_action( 'update_option', $option, $old_value, $value ); 287 292 288 293 $result = $wpdb->update( $wpdb->options, array( 'option_value' => $serialized_value ), array( 'option_name' => $option ) ); 289 if ( ! $result ) 294 if ( ! $result ) { 290 295 return false; 296 } 291 297 292 298 $notoptions = wp_cache_get( 'notoptions', 'options' ); 293 299 if ( is_array( $notoptions ) && isset( $notoptions[$option] ) ) {