Ticket #24933: 24933.diff
| File 24933.diff, 5.7 KB (added by , 13 years ago) |
|---|
-
src/wp-includes/meta.php
151 151 if ( 'post' == $meta_type ) 152 152 do_action( 'update_postmeta', $meta_id, $object_id, $meta_key, $meta_value ); 153 153 154 $wpdb->update( $table, $data, $where ); 154 $result = $wpdb->update( $table, $data, $where ); 155 if ( ! $result ) 156 return false; 155 157 156 158 wp_cache_delete($object_id, $meta_type . '_meta'); 157 159 … … 435 437 do_action( 'update_postmeta', $meta_id, $object_id, $meta_key, $meta_value ); 436 438 437 439 // Run the update query, all fields in $data are %s, $where is a %d. 438 $result = (bool) $wpdb->update( $table, $data, $where, '%s', '%d' ); 440 $result = $wpdb->update( $table, $data, $where, '%s', '%d' ); 441 if ( ! $result ) 442 return false; 439 443 440 444 // Clear the caches. 441 445 wp_cache_delete($object_id, $meta_type . '_meta'); … … 445 449 if ( 'post' == $meta_type ) 446 450 do_action( 'updated_postmeta', $meta_id, $object_id, $meta_key, $meta_value ); 447 451 448 return $result;452 return true; 449 453 } 450 454 451 455 // And if the meta was not found. -
src/wp-includes/option.php
234 234 if ( false === $oldvalue ) 235 235 return add_option( $option, $newvalue ); 236 236 237 $_newvalue = $newvalue; 238 $newvalue = maybe_serialize( $newvalue ); 239 240 $result = $wpdb->update( $wpdb->options, array( 'option_value' => $newvalue ), array( 'option_name' => $option ) ); 241 if ( ! $result ) 242 return false; 243 237 244 $notoptions = wp_cache_get( 'notoptions', 'options' ); 238 245 if ( is_array( $notoptions ) && isset( $notoptions[$option] ) ) { 239 246 unset( $notoptions[$option] ); … … 240 247 wp_cache_set( 'notoptions', $notoptions, 'options' ); 241 248 } 242 249 243 $_newvalue = $newvalue;244 $newvalue = maybe_serialize( $newvalue );245 246 250 do_action( 'update_option', $option, $oldvalue, $_newvalue ); 247 251 if ( ! defined( 'WP_INSTALLING' ) ) { 248 252 $alloptions = wp_load_alloptions(); … … 254 258 } 255 259 } 256 260 257 $result = $wpdb->update( $wpdb->options, array( 'option_value' => $newvalue ), array( 'option_name' => $option ) ); 258 259 if ( $result ) { 260 do_action( "update_option_{$option}", $oldvalue, $_newvalue ); 261 do_action( 'updated_option', $option, $oldvalue, $_newvalue ); 262 return true; 263 } 264 return false; 261 do_action( "update_option_{$option}", $oldvalue, $_newvalue ); 262 do_action( 'updated_option', $option, $oldvalue, $_newvalue ); 263 return true; 265 264 } 266 265 267 266 /** … … 312 311 if ( false !== get_option( $option ) ) 313 312 return false; 314 313 315 $_value = $value; 316 $value = maybe_serialize( $value ); 314 $_value = maybe_serialize( $value ); 317 315 $autoload = ( 'no' === $autoload ) ? 'no' : 'yes'; 318 do_action( 'add_option', $option, $_value ); 316 do_action( 'add_option', $option, $value ); 317 318 $result = $wpdb->query( $wpdb->prepare( "INSERT INTO `$wpdb->options` (`option_name`, `option_value`, `autoload`) VALUES (%s, %s, %s) ON DUPLICATE KEY UPDATE `option_name` = VALUES(`option_name`), `option_value` = VALUES(`option_value`), `autoload` = VALUES(`autoload`)", $option, $_value, $autoload ) ); 319 if ( ! $result ) 320 return false; 321 319 322 if ( ! defined( 'WP_INSTALLING' ) ) { 320 323 if ( 'yes' == $autoload ) { 321 324 $alloptions = wp_load_alloptions(); 322 $alloptions[$option] = $ value;325 $alloptions[$option] = $_value; 323 326 wp_cache_set( 'alloptions', $alloptions, 'options' ); 324 327 } else { 325 wp_cache_set( $option, $ value, 'options' );328 wp_cache_set( $option, $_value, 'options' ); 326 329 } 327 330 } 328 331 … … 333 336 wp_cache_set( 'notoptions', $notoptions, 'options' ); 334 337 } 335 338 336 $result = $wpdb->query( $wpdb->prepare( "INSERT INTO `$wpdb->options` (`option_name`, `option_value`, `autoload`) VALUES (%s, %s, %s) ON DUPLICATE KEY UPDATE `option_name` = VALUES(`option_name`), `option_value` = VALUES(`option_value`), `autoload` = VALUES(`autoload`)", $option, $value, $autoload ) ); 337 338 if ( $result ) { 339 do_action( "add_option_{$option}", $option, $_value ); 340 do_action( 'added_option', $option, $_value ); 341 return true; 342 } 343 return false; 339 do_action( "add_option_{$option}", $option, $value ); 340 do_action( 'added_option', $option, $value ); 341 return true; 344 342 } 345 343 346 344 /** … … 829 827 830 828 $value = sanitize_option( $option, $value ); 831 829 830 $_value = maybe_serialize( $value ); 831 $result = $wpdb->insert( $wpdb->sitemeta, array('site_id' => $wpdb->siteid, 'meta_key' => $option, 'meta_value' => $_value ) ); 832 833 if ( ! $result ) 834 return false; 835 832 836 wp_cache_set( $cache_key, $value, 'site-options' ); 833 837 834 $_value = $value;835 $value = maybe_serialize( $value );836 $result = $wpdb->insert( $wpdb->sitemeta, array('site_id' => $wpdb->siteid, 'meta_key' => $option, 'meta_value' => $value ) );837 $value = $_value;838 839 838 // This option exists now 840 839 $notoptions = wp_cache_get( 'notoptions', 'site-options' ); // yes, again... we need it to be fresh 841 840 if ( is_array( $notoptions ) && isset( $notoptions[$option] ) ) { … … 934 933 $result = update_option( $option, $value ); 935 934 } else { 936 935 $value = sanitize_option( $option, $value ); 937 $cache_key = "{$wpdb->siteid}:$option";938 wp_cache_set( $cache_key, $value, 'site-options' );939 936 940 $_value = $value; 941 $value = maybe_serialize( $value ); 942 $result = $wpdb->update( $wpdb->sitemeta, array( 'meta_value' => $value ), array( 'site_id' => $wpdb->siteid, 'meta_key' => $option ) ); 943 $value = $_value; 937 $_value = maybe_serialize( $value ); 938 $result = $wpdb->update( $wpdb->sitemeta, array( 'meta_value' => $_value ), array( 'site_id' => $wpdb->siteid, 'meta_key' => $option ) ); 939 940 if ( $result ) { 941 $cache_key = "{$wpdb->siteid}:$option"; 942 wp_cache_set( $cache_key, $value, 'site-options' ); 943 } 944 944 } 945 945 946 946 if ( $result ) {
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)