mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-11 20:30:23 +00:00
Site Health: Introduce persistent object cache check.
This changeset adds a new `persistent_object_cache` check which determines whether the site uses a persistent object cache, and if not, recommends it if it is beneficial for the site. A support resource to learn more about object caching has been created and is linked in the check. A few filters are included for customization of the check, aimed primarily at hosting providers to provide more specific information in regards to their environment: * `site_status_persistent_object_cache_url` filters the URL to learn more about object caching, so that e.g. a hosting-specific object caching support resource could be linked. * `site_status_persistent_object_cache_notes` filters the notes added to the check description, so that more fine tuned information on object caching based on the environment can be provided. * `site_status_should_suggest_persistent_object_cache` is a short-circuit filter which allows using entirely custom logic to determine whether a persistent object cache would make sense for the site. * `site_status_persistent_object_cache_thresholds` filters the thresholds in the default logic to determine whether a persistent object cache would make sense for the site, which is based on the amount of data in the database. Note that due to the nature of this check it is only run in production environments. Props furi3r, tillkruss, spacedmonkey, audrasjb, Clorith. Fixes #56040. git-svn-id: https://develop.svn.wordpress.org/trunk@53955 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -107,4 +107,75 @@ class Tests_Site_Health extends WP_UnitTestCase {
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group ms-excluded
|
||||
* @ticket 56040
|
||||
*/
|
||||
public function test_object_cache_default_thresholds() {
|
||||
$wp_site_health = new WP_Site_Health();
|
||||
|
||||
$this->assertFalse(
|
||||
$wp_site_health->should_suggest_persistent_object_cache()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @group ms-required
|
||||
* @ticket 56040
|
||||
*/
|
||||
public function test_object_cache_default_thresholds_on_multisite() {
|
||||
$wp_site_health = new WP_Site_Health();
|
||||
$this->assertTrue(
|
||||
$wp_site_health->should_suggest_persistent_object_cache()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 56040
|
||||
*/
|
||||
public function test_object_cache_thresholds_check_can_be_bypassed() {
|
||||
$wp_site_health = new WP_Site_Health();
|
||||
add_filter( 'site_status_should_suggest_persistent_object_cache', '__return_true' );
|
||||
|
||||
$this->assertTrue(
|
||||
$wp_site_health->should_suggest_persistent_object_cache()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider thresholds
|
||||
* @ticket 56040
|
||||
*/
|
||||
public function test_object_cache_thresholds( $threshold, $count ) {
|
||||
$wp_site_health = new WP_Site_Health();
|
||||
add_filter(
|
||||
'site_status_persistent_object_cache_thresholds',
|
||||
function ( $thresholds ) use ( $threshold, $count ) {
|
||||
return array_merge( $thresholds, array( $threshold => $count ) );
|
||||
}
|
||||
);
|
||||
|
||||
$this->assertTrue(
|
||||
$wp_site_health->should_suggest_persistent_object_cache()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Data provider.
|
||||
*
|
||||
* @ticket 56040
|
||||
*/
|
||||
public function thresholds() {
|
||||
return array(
|
||||
array( 'comments_count', 0 ),
|
||||
array( 'posts_count', 0 ),
|
||||
array( 'terms_count', 1 ),
|
||||
array( 'options_count', 100 ),
|
||||
array( 'users_count', 0 ),
|
||||
array( 'alloptions_count', 100 ),
|
||||
array( 'alloptions_bytes', 1000 ),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user