Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Jetpack sync module to sync WP Super Cache constants and global variables #6482

Merged
merged 23 commits into from
Mar 10, 2017

Conversation

gititon
Copy link
Contributor

@gititon gititon commented Feb 22, 2017

Changes proposed in this Pull Request:

  • Adds Jetpack Sync module for syncing WP Super Cache globals and constants

Testing instructions:

  • Tests have been added to the test suite for the new sync module. Additionally, you can test manually by installing WP Super Cache, changing values, and confirming that the changes values are reflected on WordPress.com.

Proposed changelog entry for your changes:

This change syncs constants and globals used by WP Super Cache. You can now whitelist additional callables for sync by adding them to the whitelist via the jetpack_sync_callable_whitelist filter.

@gititon
Copy link
Contributor Author

gititon commented Feb 22, 2017

I've created a pull request so that I can share my progress with teammates. This is a work in progress and is not meant/ready for review.

@ebinnion ebinnion assigned ebinnion and gititon and unassigned ebinnion and gititon Feb 23, 2017
@@ -293,6 +294,20 @@ static function add_woocommerce_sync_module( $sync_modules ) {
return $sync_modules;
}

static function initialize_wp_super_cache() {
//WPCACHEHOME looks like a reasonable constant to test for the plugin's presence as per https://github.com/Automattic/wp-super-cache/blob/master/wp-cache.php
if ( false === defined( 'WPCACHEHOME' ) ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @donnchawp - Since we need to check in Jetpack if WP Super Cache is active, we need to find an option, constant, etc. to check against. Is there one that you'd recommend to test against?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WPCACHEHOME should be good to use, but if you want to double check, use $wp_super_cache_debug too - it should be set to 0 or 1 and is in the sample config file so it's defined even if the user hasn't configured the plugin yet.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we could use function_exists too

@georgestephanis
Copy link
Member

Should some of the WP Super Cache stuff be in the 3rd-party directory instead?

protected $post;
protected $callable_module;
protected $full_sync;
static $woo_enabled;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably do not need this any more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, Enej. Removed.

}

function test_module_is_enabled() {
$this->assertTrue( !! Jetpack_Sync_Modules::get_module( "wp-super-cache" ) );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"wp-super-cache" could use simple quotes

$this->assertTrue( !! Jetpack_Sync_Modules::get_module( "wp-super-cache" ) );
}

//@todo test functionality
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gititon gititon force-pushed the jpop-issues-119 branch 2 times, most recently from 76a69dc to f073c7c Compare March 8, 2017 20:32
/**
* "Mocking" function so that it exists and Jetpack_Sync_Actions will load Jetpack_Sync_Module_WP_Super_Cache
*/
function wp_cache_is_enabled() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets do a if function exists here in case some one runs it with the plugin installed.

*
* @module sync
*
* @since 4.7
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We missed the 4.7 boat lets update it to 4.8

*
* @module sync
*
* @since 4.7
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We missed the 4.7 boat lets update it to 4.8

*
* @module sync
*
* @since 4.7
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We missed the 4.7 boat lets update it to 4.8

*
* @module sync
*
* @since 4.7
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We missed the 4.7 boat lets update it to 4.8

*
* @module sync
*
* @since 4.7
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here as well.

@@ -293,6 +294,20 @@ static function add_woocommerce_sync_module( $sync_modules ) {
return $sync_modules;
}

static function initialize_wp_super_cache() {
//WPCACHEHOME looks like a reasonable constant to test for the plugin's presence as per https://github.com/Automattic/wp-super-cache/blob/master/wp-cache.php
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets remove this comment. Since we are not using WPCACHEHOME constant any more.

@@ -5,6 +5,13 @@
* Just some defaults that we share with the server
*/
class Jetpack_Sync_Defaults {

static $initialized_options_whitelist;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't seem to be using these anymore :)

@@ -31,6 +31,17 @@
define( 'JETPACK_WOOCOMMERCE_INSTALL_DIR', dirname( __FILE__ ) . '/../../../woocommerce' );
}

if ( "1" != getenv( 'JETPACK_TEST_WP_SUPER_CACHE' ) ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"1" could be written as '1' to match coding standards

@@ -31,6 +31,17 @@
define( 'JETPACK_WOOCOMMERCE_INSTALL_DIR', dirname( __FILE__ ) . '/../../../woocommerce' );
}

if ( "1" != getenv( 'JETPACK_TEST_WP_SUPER_CACHE' ) ) {
echo "To run Jetpack WP Super Cache tests, prefix phpunit with JETPACK_TEST_WP_SUPER_CACHE=1" . PHP_EOL;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same :)

gititon added 14 commits March 10, 2017 09:56
…enabled() instead of if WPCACHEHOME is defined in case the latter is left behind by a config file.
…listing mechanism for WP Super Cache Module

Updated "default" whitelisting mechanism to ensure filters (which add values  to whitelisted array) are only run once when getters are called so that they don't repeatedly add the same values if getters are called again.

Using mechanism to add values to constant and callable whitelists to sync WP Super Cache data.
Copy link
Contributor

@lezama lezama left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work 👍

@gititon gititon changed the title Jetpack Sync: First pass at WP Super Cache integration. Add Jetpack sync module to sync WP Super Cache constants and global variables Mar 10, 2017
@gititon gititon merged commit a773fe3 into master Mar 10, 2017
@gititon gititon deleted the jpop-issues-119 branch March 10, 2017 21:36
jeherve added a commit that referenced this pull request Mar 28, 2017
samhotchkiss pushed a commit that referenced this pull request Mar 29, 2017
* Readme: remove old release and add skeleton for 4.8.

* Changelog: add #6572

* Changelog: add #6567

* Changelog: add #6542

* Changelog: add #6527

* Changelog: add #6508

* Changelog: add #6478

* Changelog: add #6477

* Changelog: add #6249

* Update stable version and remove old version from readme.

* Changelog: add 4.7.1 to changelog.

* Readme: add new contributor.

* Sync: update docblock @SInCE version.

Related: #6053

* Changelog: add release post.

* changelog: add #6053

* Changelog: add #6413

* Changelog: add #6482

* Changelog: add #6584

* Changelog add #6603

* Changelog: add #6606

* Changelog: add #6611

* Changelog: add #6635

* Changelog: add #6639

* Changelog: add #6684

* Changelog: add #6710

* Changelog: add #6711

* Changelog: add #5461

* Testing list: update Settings UI feedback prompt.

Props @MichaelArestad

* Changelog: add #6789

* Changelog: add #6778

* Changelog: add #6777

* Changelog: add #6775

* Changelog: add #6755

* Changelog: add #6731

* Changelog: add #6721

* Changelog: add #6705

* Changelog: add #6702

* Changelog: add #6671

* Changelog: add #6637

* Changelog: add #6582

* Changelog: add #6566

* Changelog: add #6555

* Changelog: add #6529

* Changelog: add #6344

* Changelog: add #5763

* Changelog: add #5503

* Changelog: update #6637 changelog.

@see 40e115c#commitcomment-21523982

* Changelog: add #6699

* Changelog: add #6632

* Changelog: add #6769

* Changelog: add #6707

* Changelog: add #6590
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants