-
Notifications
You must be signed in to change notification settings - Fork 815
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
Conversation
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. |
sync/class.jetpack-sync-actions.php
Outdated
@@ -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' ) ) { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
Should some of the WP Super Cache stuff be in the |
protected $post; | ||
protected $callable_module; | ||
protected $full_sync; | ||
static $woo_enabled; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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" ) ); |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could add something similar to this test: https://github.com/Automattic/jetpack/blob/master/tests/php/sync/test_class.jetpack-sync-options.php#L65
76a69dc
to
f073c7c
Compare
tests/php/bootstrap.php
Outdated
/** | ||
* "Mocking" function so that it exists and Jetpack_Sync_Actions will load Jetpack_Sync_Module_WP_Super_Cache | ||
*/ | ||
function wp_cache_is_enabled() { |
There was a problem hiding this comment.
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.
sync/class.jetpack-sync-defaults.php
Outdated
* | ||
* @module sync | ||
* | ||
* @since 4.7 |
There was a problem hiding this comment.
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
sync/class.jetpack-sync-defaults.php
Outdated
* | ||
* @module sync | ||
* | ||
* @since 4.7 |
There was a problem hiding this comment.
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
sync/class.jetpack-sync-defaults.php
Outdated
* | ||
* @module sync | ||
* | ||
* @since 4.7 |
There was a problem hiding this comment.
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
sync/class.jetpack-sync-defaults.php
Outdated
* | ||
* @module sync | ||
* | ||
* @since 4.7 |
There was a problem hiding this comment.
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
sync/class.jetpack-sync-defaults.php
Outdated
* | ||
* @module sync | ||
* | ||
* @since 4.7 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here as well.
sync/class.jetpack-sync-actions.php
Outdated
@@ -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 |
There was a problem hiding this comment.
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.
sync/class.jetpack-sync-defaults.php
Outdated
@@ -5,6 +5,13 @@ | |||
* Just some defaults that we share with the server | |||
*/ | |||
class Jetpack_Sync_Defaults { | |||
|
|||
static $initialized_options_whitelist; |
There was a problem hiding this comment.
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 :)
tests/php/bootstrap.php
Outdated
@@ -31,6 +31,17 @@ | |||
define( 'JETPACK_WOOCOMMERCE_INSTALL_DIR', dirname( __FILE__ ) . '/../../../woocommerce' ); | |||
} | |||
|
|||
if ( "1" != getenv( 'JETPACK_TEST_WP_SUPER_CACHE' ) ) { |
There was a problem hiding this comment.
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
tests/php/bootstrap.php
Outdated
@@ -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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same :)
…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.
…on before defining it
a645f85
to
4c97aaa
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work 👍
* 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
Changes proposed in this Pull Request:
Testing instructions:
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.