Skip to content

Commit

Permalink
Prevent absent version from being supplied by current version in upda…
Browse files Browse the repository at this point in the history
…te check
  • Loading branch information
westonruter committed Oct 4, 2018
1 parent a363e66 commit 050f7bc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
10 changes: 8 additions & 2 deletions amp.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,14 @@ function amp_init() {
// Add actions for legacy post templates.
add_action( 'wp', 'amp_maybe_add_actions' );

// Broadcast plugin updates.
$old_version = AMP_Options_Manager::get_option( 'version', '0.0' );
/*
* Broadcast plugin updates.
* Note that AMP_Options_Manager::get_option( 'version', '0.0' ) cannot be used because
* version was new option added, and in that case default would never be used for a site
* upgrading from a version prior to 1.0. So this is why get_option() is currently used.
*/
$options = get_option( AMP_Options_Manager::OPTION_NAME, array() );
$old_version = isset( $options['version'] ) ? $options['version'] : '0.0';
if ( AMP__VERSION !== $old_version ) {
/**
* Triggers when after amp_init when the plugin version has updated.
Expand Down
1 change: 1 addition & 0 deletions tests/test-class-amp-theme-support.php
Original file line number Diff line number Diff line change
Expand Up @@ -1318,6 +1318,7 @@ public function test_post_processor_cache_effectiveness() {
$args = array( 'enable_response_caching' => true );
wp_using_ext_object_cache( true ); // turn on external object cache flag.
$this->reset_post_processor_cache_effectiveness();
AMP_Options_Manager::update_option( 'enable_response_caching', true );

// Test the response is not cached after exceeding the cache miss threshold.
for ( $num_calls = 1, $max = AMP_Theme_Support::CACHE_MISS_THRESHOLD + 2; $num_calls <= $max; $num_calls++ ) {
Expand Down

0 comments on commit 050f7bc

Please sign in to comment.