Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ function perflab_oc_health_persistent_object_cache() {
return $result;
}

if ( ! perflab_oc_health_should_persistent_object_cache() ) {
if ( ! perflab_oc_health_should_suggest_persistent_object_cache() ) {
$result['label'] = __( 'A persistent object cache is not required', 'performance-lab' );

return $result;
Expand Down Expand Up @@ -135,9 +135,13 @@ function perflab_oc_health_persistent_object_cache() {
*
* @return bool Whether to suggest using a persistent object cache.
*/
function perflab_oc_health_should_persistent_object_cache() {
function perflab_oc_health_should_suggest_persistent_object_cache() {
global $wpdb;

if ( is_multisite() ) {
return true;
}

/**
* Filter to force suggestion to use a persistent object cache and bypass threshold checks.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,29 @@

class Object_Cache_Health_Check_Tests extends WP_UnitTestCase {

/**
* @group ms-excluded
*/
function test_object_cache_default_thresholds() {
$this->assertFalse(
perflab_oc_health_should_persistent_object_cache()
perflab_oc_health_should_suggest_persistent_object_cache()
);
}

/**
* @group ms-required
*/
function test_object_cache_default_thresholds_on_multisite() {
$this->assertTrue(
perflab_oc_health_should_suggest_persistent_object_cache()
);
}

function test_object_cache_thresholds_check_can_be_bypassed() {
add_filter( 'perflab_oc_site_status_suggest_persistent_object_cache', '__return_true' );

$this->assertTrue(
perflab_oc_health_should_persistent_object_cache()
perflab_oc_health_should_suggest_persistent_object_cache()
);
}

Expand All @@ -34,7 +46,7 @@ function ( $thresholds ) use ( $threshold, $count ) {
);

$this->assertTrue(
perflab_oc_health_should_persistent_object_cache()
perflab_oc_health_should_suggest_persistent_object_cache()
);
}

Expand Down