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

[CMSP-624] Check for and recommend Object Cache Pro #147

Merged
merged 8 commits into from
Aug 23, 2023
Merged
Show file tree
Hide file tree
Changes from 4 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
6 changes: 3 additions & 3 deletions features/objectcache.feature
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Feature: Suggest object cache to be enabled
"""
And STDOUT should contain:
"""
<p class="result">Use Redis with the WP Redis object cache drop-in
<p class="result">Use Object Cache Pro to speed up your backend
"""

Scenario: An object cache is present but it's not WP Redis
jazzsequence marked this conversation as resolved.
Show resolved Hide resolved
Expand All @@ -25,7 +25,7 @@ Feature: Suggest object cache to be enabled
"""
And STDOUT should contain:
"""
<p class="result">Use Redis with the WP Redis object cache drop-in
<p class="result">Use Object Cache Pro to speed up your backend
"""

Scenario: WP Redis is present as the enabled object-cache
Expand All @@ -41,5 +41,5 @@ Feature: Suggest object cache to be enabled
"""
And STDOUT should contain:
"""
<p class="result">Redis found
<p class="result">WP Redis for object caching was found. We recommend using Object Cache Pro
"""
11 changes: 7 additions & 4 deletions php/pantheon/checks/objectcache.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,14 @@ public function run() {
} else {
$this->alerts[] = array("message"=> "object-cache.php exists", "code" => 0);
}

if ( ! defined( 'WP_REDIS_OBJECT_CACHE' ) || ! WP_REDIS_OBJECT_CACHE ) {
jazzsequence marked this conversation as resolved.
Show resolved Hide resolved
$this->alerts[] = array("message"=> 'Use Redis with the WP Redis object cache drop-in to speed up your backend. <a href="https://pantheon.io/docs/wordpress-redis/" target="_blank">Learn More</a>', "code" => 1);
} else {
$this->alerts[] = array("message"=> "Redis found", "code" => 0);
$this->alerts[] = array('message'=> 'WP Redis for object caching was found. We recommend using Object Cache Pro as a replacement. <a href="https://docs.pantheon.io/guides/object-cache-pro/installing-configuring/" target="_blank">Learn More</a> about how to install Object Cache Pro.', 'code' => 1);
}
if ( ! defined( 'WP_REDIS_CONFIG' ) || ! WP_REDIS_CONFIG ) {
rachelwhitton marked this conversation as resolved.
Show resolved Hide resolved
jazzsequence marked this conversation as resolved.
Show resolved Hide resolved
$this->alerts[] = array("message"=> 'Use Object Cache Pro to speed up your backend. <a href="https://docs.pantheon.io/guides/object-cache-pro/installing-configuring/" target="_blank">Learn More</a>', "code" => 1);
} else {
$this->alerts[] = array("message"=> "Object Cache Pro found", "code" => 0);
}

return $this;
Expand All @@ -57,7 +60,7 @@ public function message(Messenger $messenger) {
$avg = $total/count($this->alerts);
$this->result = View::make('checklist', array('rows'=> $rows) );
$this->score = $avg;
$this->action = "You should use object caching";
$this->action = "You should use Object Cache Pro";
}
$messenger->addMessage(get_object_vars($this));
}
Expand Down
Loading