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 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
2 changes: 1 addition & 1 deletion features/general.feature
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Feature: General tests of WP Launch Check
# This check is here to remind us to update versions when new releases are available.
Then STDOUT should contain:
"""
6.2
6.3
"""

When I run `wp launchcheck general`
Expand Down
8 changes: 4 additions & 4 deletions features/objectcache.feature
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ 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
Scenario: An object cache is present but it's not Object Cache Pro
Given a WP install
And I run `wp plugin install wp-lcache --activate`
And I run `wp lcache enable`
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: 6 additions & 5 deletions php/pantheon/checks/objectcache.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,12 @@ public function run() {
} else {
$this->alerts[] = array("message"=> "object-cache.php exists", "code" => 0);
}

if ( ! defined( 'WP_REDIS_OBJECT_CACHE' ) || ! WP_REDIS_OBJECT_CACHE ) {
$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);
if ( defined( 'WP_REDIS_OBJECT_CACHE' )) {
$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);
} elseif ( ! defined( 'WP_REDIS_CONFIG' ) || ! WP_REDIS_CONFIG ) {
$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"=> "Redis found", "code" => 0);
$this->alerts[] = array("message"=> "Object Cache Pro found", "code" => 0);
}

return $this;
Expand All @@ -57,7 +58,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