Ticket #32452: 5vPGCCt7.diff
File 5vPGCCt7.diff, 11.7 KB (added by , 10 years ago) |
---|
-
src/wp-includes/cache.php
24 24 function wp_cache_add( $key, $data, $group = '', $expire = 0 ) { 25 25 global $wp_object_cache; 26 26 27 error_log('@@@@@@@@@@@@@ wp_cache_add ############' . $key. ' ' . $group); 28 if ($key == 'alloptions') { 29 if (!is_array($data)) 30 error_log('@@@@@@@@@@@@@ wp_cache_add got non array as data ###########'); 31 $i = 0; 32 foreach($data as $k => $v) { //isn't serialized yet 33 if ($wp_object_cache->add( $k, $v, $group, $expire )) //if does not return false 34 $i++; 35 } 36 error_log("@@@@@@@@@@@@@ Added $i keys from alloptions ############"); 37 } 38 27 39 return $wp_object_cache->add( $key, $data, $group, (int) $expire ); 28 40 } 29 41 … … 139 151 */ 140 152 function wp_cache_init() { 141 153 $GLOBALS['wp_object_cache'] = new WP_Object_Cache(); 154 155 wp_load_alloptions(); //load all the options into the cache 142 156 } 143 157 144 158 -
src/wp-includes/default-widgets.php
744 744 $instance['show_date'] = isset( $new_instance['show_date'] ) ? (bool) $new_instance['show_date'] : false; 745 745 $this->flush_widget_cache(); 746 746 747 $alloptions = wp_cache_get( 'alloptions', 'options' ); 748 if ( isset($alloptions['widget_recent_entries']) ) 749 delete_option('widget_recent_entries'); 747 //$alloptions = wp_cache_get( 'alloptions', 'options' ); 748 //if ( isset($alloptions['widget_recent_entries']) ) 749 if (wp_cache_get('widget_recent_entries', 'options')) //save db time just check cache 750 delete_option('widget_recent_entries'); //delete from DB if it existed 750 751 751 752 return $instance; 752 753 } … … 897 898 $instance['number'] = absint( $new_instance['number'] ); 898 899 $this->flush_widget_cache(); 899 900 900 $alloptions = wp_cache_get( 'alloptions', 'options' ); 901 if ( isset($alloptions['widget_recent_comments']) ) 901 //$alloptions = wp_cache_get( 'alloptions', 'options' ); 902 //if ( isset($alloptions['widget_recent_comments']) ) 903 if (wp_cache_get('widget_recent_comments', 'options')) 902 904 delete_option('widget_recent_comments'); 903 905 904 906 return $instance; -
src/wp-includes/formatting.php
602 602 if ( ! $charset ) { 603 603 static $_charset; 604 604 if ( ! isset( $_charset ) ) { 605 $alloptions = wp_load_alloptions(); 606 $_charset = isset( $alloptions['blog_charset'] ) ? $alloptions['blog_charset'] : ''; 605 //$alloptions = wp_load_alloptions(); 606 //$_charset = isset( $alloptions['blog_charset'] ) ? $alloptions['blog_charset'] : ''; 607 $_charset = get_option('blog_charset', ''); //this will try the cache first 607 608 } 608 609 $charset = $_charset; 609 610 } -
src/wp-includes/functions.php
1268 1288 return true; 1269 1289 1270 1290 $suppress = $wpdb->suppress_errors(); 1291 /* 1271 1292 if ( ! defined( 'WP_INSTALLING' ) ) { 1272 1293 $alloptions = wp_load_alloptions(); 1273 1294 } … … 1276 1297 $installed = $wpdb->get_var( "SELECT option_value FROM $wpdb->options WHERE option_name = 'siteurl'" ); 1277 1298 else 1278 1299 $installed = $alloptions['siteurl']; 1300 */ 1301 $installed = get_option('siteurl'); //this looks equivalent 1302 1279 1303 $wpdb->suppress_errors( $suppress ); 1280 1304 1281 1305 $installed = !empty( $installed ); -
src/wp-includes/option.php
49 49 if ( defined( 'WP_SETUP_CONFIG' ) ) 50 50 return false; 51 51 52 if ( ! defined( 'WP_INSTALLING' ) ) { 53 // prevent non-existent options from triggering multiple queries 52 if ( ! defined( 'WP_INSTALLING' ) ) { 53 54 $value = wp_cache_get( $option, 'options' ); 55 if ( false === $value ) { //if we didn't get anything back from the cache 56 //check the notoptions 54 57 $notoptions = wp_cache_get( 'notoptions', 'options' ); 55 58 if ( isset( $notoptions[ $option ] ) ) { 56 59 … … 66 69 return apply_filters( 'default_option_' . $option, $default ); 67 70 } 68 71 69 $alloptions = wp_load_alloptions(); 70 71 if ( isset( $alloptions[$option] ) ) { 72 $value = $alloptions[$option]; 73 } else { 74 $value = wp_cache_get( $option, 'options' ); 75 76 if ( false === $value ) { 72 //if we got this far, and we still don't have the value, then request from the DB 77 73 $row = $wpdb->get_row( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = %s LIMIT 1", $option ) ); 78 74 79 75 // Has to be get_row instead of get_var because of funkiness with 0, false, null values … … 88 84 return apply_filters( 'default_option_' . $option, $default ); 89 85 } 90 86 } 91 }92 87 } else { 93 88 $suppress = $wpdb->suppress_errors(); 94 89 $row = $wpdb->get_row( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = %s LIMIT 1", $option ) ); … … (this hunk was shorter than expected) 106 101 return get_option( 'siteurl' ); 107 102 108 103 if ( in_array( $option, array('siteurl', 'home', 'category_base', 'tag_base') ) ) 109 $value = untrailingslashit( $value );110 104 $value = rtrim( $value, '/\\' ); //$value = untrailingslashit( $value ); //untrailingslashit does not yet exist if called from within functions.php 105 111 106 … … 284 279 285 280 do_action( 'update_option', $option, $old_value, $value ); 286 281 282 //what cases does $result == false? 283 //if argument 2 or 3 are not arrays 284 //prepare() returns '' if query is null (which it isnt) 285 //query() returns false if $this->ready is false 286 //also if db_connection does not exist 287 //the mysql query generated an error 288 //or if rows effected == 0 287 289 $result = $wpdb->update( $wpdb->options, array( 'option_value' => $serialized_value ), array( 'option_name' => $option ) ); 288 if ( ! $result )290 if ( ! $result && ! $result == 0) { //if update affected zero rows we still want to try to update the cache anyways 289 291 return false; 292 } 290 293 294 //remove it from notoptions if it was there 291 295 $notoptions = wp_cache_get( 'notoptions', 'options' ); 292 296 if ( is_array( $notoptions ) && isset( $notoptions[$option] ) ) { 293 297 unset( $notoptions[$option] ); … … (this hunk was shorter than expected) 295 299 } 296 300 297 301 if ( ! defined( 'WP_INSTALLING' ) ) { 298 $alloptions = wp_load_alloptions();299 if ( isset( $alloptions[$option] ) ) {300 $alloptions[ $option ] = $serialized_value;301 wp_cache_set( 'alloptions', $alloptions, 'options' );302 } else {302 //$alloptions = wp_load_alloptions(); 303 //if ( isset( $alloptions[$option] ) ) { 304 // $alloptions[ $option ] = $serialized_value; 305 // wp_cache_set( 'alloptions', $alloptions, 'options' ); 306 //} else { 303 307 wp_cache_set( $option, $serialized_value, 'options' ); 308 //} 304 309 } 305 }306 310 307 311 … … (this hunk was shorter than expected) 315 319 316 320 do_action( "update_option_{$option}", $old_value, $value ); 317 321 318 322 /** 319 323 * Fires after the value of an option has been successfully updated. 320 324 * … … 385 389 */ 386 390 do_action( 'add_option', $option, $value ); 387 391 392 //why on update clause, didn't we just check a bunch of times whether the option already existed? 388 393 $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, $serialized_value, $autoload ) ); 389 394 if ( ! $result ) 390 395 return false; 391 396 392 397 if ( ! defined( 'WP_INSTALLING' ) ) { 393 if ( 'yes' == $autoload ) {394 $alloptions = wp_load_alloptions();395 $alloptions[ $option ] = $serialized_value;396 wp_cache_set( 'alloptions', $alloptions, 'options' );397 } else {398 //if ( 'yes' == $autoload ) { 399 //$alloptions = wp_load_alloptions(); 400 // $alloptions[ $option ] = $serialized_value; 401 // wp_cache_set( 'alloptions', $alloptions, 'options' ); 402 //} else { 398 403 wp_cache_set( $option, $serialized_value, 'options' ); 404 //} 399 405 } 400 }401 406 402 407 // This option exists now 403 408 $notoptions = wp_cache_get( 'notoptions', 'options' ); // yes, again... we need it to be fresh 409 //but why must it be fresh? I guess another query might have run in the meantime? 404 410 if ( is_array( $notoptions ) && isset( $notoptions[$option] ) ) { 405 411 unset( $notoptions[$option] ); 406 412 wp_cache_set( 'notoptions', $notoptions, 'options' ); … … 449 455 wp_protect_special_option( $option ); 450 456 451 457 // Get the ID, if no ID then return 458 //checking if the option exists to be deleted 452 459 $row = $wpdb->get_row( $wpdb->prepare( "SELECT autoload FROM $wpdb->options WHERE option_name = %s", $option ) ); 453 460 if ( is_null( $row ) ) 454 461 return false; … … 464 471 465 472 $result = $wpdb->delete( $wpdb->options, array( 'option_name' => $option ) ); 466 473 if ( ! defined( 'WP_INSTALLING' ) ) { 467 if ( 'yes' == $row->autoload ) {468 $alloptions = wp_load_alloptions();469 if ( is_array( $alloptions ) && isset( $alloptions[$option] ) ) {470 unset( $alloptions[$option] );471 wp_cache_set( 'alloptions', $alloptions, 'options' );472 }473 } else {474 //if ( 'yes' == $row->autoload ) { 475 // $alloptions = wp_load_alloptions(); 476 // if ( is_array( $alloptions ) && isset( $alloptions[$option] ) ) { 477 // unset( $alloptions[$option] ); 478 // wp_cache_set( 'alloptions', $alloptions, 'options' ); 479 // } 480 //} else { 474 481 wp_cache_delete( $option, 'options' ); 482 //} 475 483 } 476 }477 484 if ( $result ) { 478 485 //now to pre-emptively cache the negative result of the newly deleted option 486 $notoptions = wp_cache_get( 'notoptions', 'options' ); 487 $notoptions[$option] = true; 488 wp_cache_set( 'notoptions', $notoptions, 'options' ); 489 479 490 /** 480 491 * Fires after a specific option has been deleted. 481 492 *