Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --- commonFiles/wordpress_from_svn/wp-includes/cache.php (revision 32479)
- +++ commonFiles/wordpress_from_svn/wp-includes/cache.php (working copy)
- @@ -24,6 +24,18 @@
- function wp_cache_add( $key, $data, $group = '', $expire = 0 ) {
- global $wp_object_cache;
- + error_log('@@@@@@@@@@@@@ wp_cache_add ############' . $key. ' ' . $group);
- + if ($key == 'alloptions') {
- + if (!is_array($data))
- + error_log('@@@@@@@@@@@@@ wp_cache_add got non array as data ###########');
- + $i = 0;
- + foreach($data as $k => $v) { //isn't serialized yet
- + if ($wp_object_cache->add( $k, $v, $group, $expire )) //if does not return false
- + $i++;
- + }
- + error_log("@@@@@@@@@@@@@ Added $i keys from alloptions ############");
- + }
- +
- return $wp_object_cache->add( $key, $data, $group, (int) $expire );
- }
- @@ -139,6 +151,8 @@
- */
- function wp_cache_init() {
- $GLOBALS['wp_object_cache'] = new WP_Object_Cache();
- +
- + wp_load_alloptions(); //load all the options into the cache
- }
- /**
- --- commonFiles/wordpress_from_svn/wp-includes/default-widgets.php (revision 32479)
- +++ commonFiles/wordpress_from_svn/wp-includes/default-widgets.php (working copy)
- @@ -744,9 +744,10 @@
- $instance['show_date'] = isset( $new_instance['show_date'] ) ? (bool) $new_instance['show_date'] : false;
- $this->flush_widget_cache();
- - $alloptions = wp_cache_get( 'alloptions', 'options' );
- - if ( isset($alloptions['widget_recent_entries']) )
- - delete_option('widget_recent_entries');
- + //$alloptions = wp_cache_get( 'alloptions', 'options' );
- + //if ( isset($alloptions['widget_recent_entries']) )
- + if (wp_cache_get('widget_recent_entries', 'options')) //save db time just check cache
- + delete_option('widget_recent_entries'); //delete from DB if it existed
- return $instance;
- }
- @@ -897,8 +898,9 @@
- $instance['number'] = absint( $new_instance['number'] );
- $this->flush_widget_cache();
- - $alloptions = wp_cache_get( 'alloptions', 'options' );
- - if ( isset($alloptions['widget_recent_comments']) )
- + //$alloptions = wp_cache_get( 'alloptions', 'options' );
- + //if ( isset($alloptions['widget_recent_comments']) )
- + if (wp_cache_get('widget_recent_comments', 'options'))
- delete_option('widget_recent_comments');
- return $instance;
- --- commonFiles/wordpress_from_svn/wp-includes/formatting.php (revision 32479)
- +++ commonFiles/wordpress_from_svn/wp-includes/formatting.php (working copy)
- @@ -602,8 +602,9 @@
- if ( ! $charset ) {
- static $_charset;
- if ( ! isset( $_charset ) ) {
- - $alloptions = wp_load_alloptions();
- - $_charset = isset( $alloptions['blog_charset'] ) ? $alloptions['blog_charset'] : '';
- + //$alloptions = wp_load_alloptions();
- + //$_charset = isset( $alloptions['blog_charset'] ) ? $alloptions['blog_charset'] : '';
- + $_charset = get_option('blog_charset', ''); //this will try the cache first
- }
- $charset = $_charset;
- }
- --- commonFiles/wordpress_from_svn/wp-includes/functions.php (revision 32479)
- +++ commonFiles/wordpress_from_svn/wp-includes/functions.php (working copy)
- @@ -1268,6 +1288,7 @@
- return true;
- $suppress = $wpdb->suppress_errors();
- +/*
- if ( ! defined( 'WP_INSTALLING' ) ) {
- $alloptions = wp_load_alloptions();
- }
- @@ -1276,6 +1297,9 @@
- $installed = $wpdb->get_var( "SELECT option_value FROM $wpdb->options WHERE option_name = 'siteurl'" );
- else
- $installed = $alloptions['siteurl'];
- +*/
- + $installed = get_option('siteurl'); //this looks equivalent
- +
- $wpdb->suppress_errors( $suppress );
- $installed = !empty( $installed );
- --- commonFiles/wordpress_from_svn/wp-includes/option.php (revision 32479)
- +++ commonFiles/wordpress_from_svn/wp-includes/option.php (working copy)
- @@ -49,8 +49,11 @@
- if ( defined( 'WP_SETUP_CONFIG' ) )
- return false;
- - if ( ! defined( 'WP_INSTALLING' ) ) {
- - // prevent non-existent options from triggering multiple queries
- + if ( ! defined( 'WP_INSTALLING' ) ) {
- +
- + $value = wp_cache_get( $option, 'options' );
- + if ( false === $value ) { //if we didn't get anything back from the cache
- + //check the notoptions
- $notoptions = wp_cache_get( 'notoptions', 'options' );
- if ( isset( $notoptions[ $option ] ) ) {
- /**
- @@ -66,14 +69,7 @@
- return apply_filters( 'default_option_' . $option, $default );
- }
- - $alloptions = wp_load_alloptions();
- -
- - if ( isset( $alloptions[$option] ) ) {
- - $value = $alloptions[$option];
- - } else {
- - $value = wp_cache_get( $option, 'options' );
- -
- - if ( false === $value ) {
- + //if we got this far, and we still don't have the value, then request from the DB
- $row = $wpdb->get_row( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = %s LIMIT 1", $option ) );
- // Has to be get_row instead of get_var because of funkiness with 0, false, null values
- @@ -88,7 +84,6 @@
- return apply_filters( 'default_option_' . $option, $default );
- }
- }
- - }
- } else {
- $suppress = $wpdb->suppress_errors();
- $row = $wpdb->get_row( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = %s LIMIT 1", $option ) );
- @@ -106,8 +101,8 @@
- return get_option( 'siteurl' );
- if ( in_array( $option, array('siteurl', 'home', 'category_base', 'tag_base') ) )
- - $value = untrailingslashit( $value );
- -
- + $value = rtrim( $value, '/\\' ); //$value = untrailingslashit( $value ); //untrailingslashit does not yet exist if called from within functions.php
- +
- /**
- * Filter the value of an existing option.
- *
- @@ -284,10 +279,19 @@
- */
- do_action( 'update_option', $option, $old_value, $value );
- + //what cases does $result == false?
- + //if argument 2 or 3 are not arrays
- + //prepare() returns '' if query is null (which it isnt)
- + //query() returns false if $this->ready is false
- + //also if db_connection does not exist
- + //the mysql query generated an error
- + //or if rows effected == 0
- $result = $wpdb->update( $wpdb->options, array( 'option_value' => $serialized_value ), array( 'option_name' => $option ) );
- - if ( ! $result )
- + if ( ! $result && ! $result == 0) { //if update affected zero rows we still want to try to update the cache anyways
- return false;
- + }
- + //remove it from notoptions if it was there
- $notoptions = wp_cache_get( 'notoptions', 'options' );
- if ( is_array( $notoptions ) && isset( $notoptions[$option] ) ) {
- unset( $notoptions[$option] );
- @@ -295,14 +299,14 @@
- }
- if ( ! defined( 'WP_INSTALLING' ) ) {
- - $alloptions = wp_load_alloptions();
- - if ( isset( $alloptions[$option] ) ) {
- - $alloptions[ $option ] = $serialized_value;
- - wp_cache_set( 'alloptions', $alloptions, 'options' );
- - } else {
- + //$alloptions = wp_load_alloptions();
- + //if ( isset( $alloptions[$option] ) ) {
- + // $alloptions[ $option ] = $serialized_value;
- + // wp_cache_set( 'alloptions', $alloptions, 'options' );
- + //} else {
- wp_cache_set( $option, $serialized_value, 'options' );
- + //}
- }
- - }
- /**
- * Fires after the value of a specific option has been successfully updated.
- @@ -315,7 +319,7 @@
- * @param mixed $value The new option value.
- */
- do_action( "update_option_{$option}", $old_value, $value );
- -
- +
- /**
- * Fires after the value of an option has been successfully updated.
- *
- @@ -385,22 +389,24 @@
- */
- do_action( 'add_option', $option, $value );
- + //why on update clause, didn't we just check a bunch of times whether the option already existed?
- $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 ) );
- if ( ! $result )
- return false;
- -
- +
- if ( ! defined( 'WP_INSTALLING' ) ) {
- - if ( 'yes' == $autoload ) {
- - $alloptions = wp_load_alloptions();
- - $alloptions[ $option ] = $serialized_value;
- - wp_cache_set( 'alloptions', $alloptions, 'options' );
- - } else {
- + //if ( 'yes' == $autoload ) {
- + //$alloptions = wp_load_alloptions();
- + // $alloptions[ $option ] = $serialized_value;
- + // wp_cache_set( 'alloptions', $alloptions, 'options' );
- + //} else {
- wp_cache_set( $option, $serialized_value, 'options' );
- + //}
- }
- - }
- // This option exists now
- $notoptions = wp_cache_get( 'notoptions', 'options' ); // yes, again... we need it to be fresh
- + //but why must it be fresh? I guess another query might have run in the meantime?
- if ( is_array( $notoptions ) && isset( $notoptions[$option] ) ) {
- unset( $notoptions[$option] );
- wp_cache_set( 'notoptions', $notoptions, 'options' );
- @@ -449,6 +455,7 @@
- wp_protect_special_option( $option );
- // Get the ID, if no ID then return
- + //checking if the option exists to be deleted
- $row = $wpdb->get_row( $wpdb->prepare( "SELECT autoload FROM $wpdb->options WHERE option_name = %s", $option ) );
- if ( is_null( $row ) )
- return false;
- @@ -464,18 +471,22 @@
- $result = $wpdb->delete( $wpdb->options, array( 'option_name' => $option ) );
- if ( ! defined( 'WP_INSTALLING' ) ) {
- - if ( 'yes' == $row->autoload ) {
- - $alloptions = wp_load_alloptions();
- - if ( is_array( $alloptions ) && isset( $alloptions[$option] ) ) {
- - unset( $alloptions[$option] );
- - wp_cache_set( 'alloptions', $alloptions, 'options' );
- - }
- - } else {
- + //if ( 'yes' == $row->autoload ) {
- + // $alloptions = wp_load_alloptions();
- + // if ( is_array( $alloptions ) && isset( $alloptions[$option] ) ) {
- + // unset( $alloptions[$option] );
- + // wp_cache_set( 'alloptions', $alloptions, 'options' );
- + // }
- + //} else {
- wp_cache_delete( $option, 'options' );
- + //}
- }
- - }
- if ( $result ) {
- -
- + //now to pre-emptively cache the negative result of the newly deleted option
- + $notoptions = wp_cache_get( 'notoptions', 'options' );
- + $notoptions[$option] = true;
- + wp_cache_set( 'notoptions', $notoptions, 'options' );
- +
- /**
- * Fires after a specific option has been deleted.
- *
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement