Making WordPress.org

Changeset 4412


Ignore:
Timestamp:
11/24/2016 04:15:39 AM (8 years ago)
Author:
tellyworth
Message:

Plugin directory: attempt to work around a race condition or similar caching bug that is preventing sync from completing.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-plugin-directory.php

    r4406 r4412  
    6262        // Load the API routes.
    6363        add_action( 'rest_api_init', array( __NAMESPACE__ . '\API\Base', 'load_routes' ) );
     64
     65        // Work around caching issues
     66        add_filter( 'pre_option_jetpack_sync_full__started' , array( $this, 'bypass_options_cache' ), 10, 2 );
     67        add_filter( 'pre_option_jetpack_sync_full__params' , array( $this, 'bypass_options_cache' ), 10, 2 );
     68        add_filter( 'pre_option_jetpack_sync_full__queue_finished' , array( $this, 'bypass_options_cache' ), 10, 2 );
     69        add_filter( 'pre_option_jetpack_sync_full__send_started' , array( $this, 'bypass_options_cache' ), 10, 2 );
     70        add_filter( 'pre_option_jetpack_sync_full__finished' , array( $this, 'bypass_options_cache' ), 10, 2 );
    6471
    6572        /*
     
    633640            $wp_query->query_vars['meta_key'] = '_active_installs';
    634641        }
     642    }
     643
     644    /**
     645     * Filter to bypass caching for options critical to Jetpack sync to work around race conditions and other unidentified bugs.
     646     * If this works and becomes a permanent solution, it probably belongs elsewhere.
     647     */
     648    public function bypass_options_cache( $value, $option ) {
     649        global $wpdb;
     650        $value = $wpdb->get_var(
     651            $wpdb->prepare(
     652                "SELECT option_value FROM $wpdb->options WHERE option_name = %s LIMIT 1",
     653                $option
     654            )
     655        );
     656        $value = maybe_unserialize( $value );
     657
     658        return $value;
    635659    }
    636660
Note: See TracChangeset for help on using the changeset viewer.