Skip to content

Commit

Permalink
Merge branch 'release/3.5.39'
Browse files Browse the repository at this point in the history
  • Loading branch information
andykillen committed Sep 30, 2024
2 parents 4b4c72c + 66cace1 commit 1074f81
Show file tree
Hide file tree
Showing 9 changed files with 62 additions and 35 deletions.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,13 @@ If you want to build a local production-ready version of the plugin you can run

## Changelog

#### 3.5.37
#### 3.5.39
* Added sanitization to host calls for purging, and better validation, via update to Servebolt SDK.
* Made purge based AJAX error messages readable in the modal window.
* Reduced number of cache tags, removing ones that were never used.
* Adapted purge call for Servebolt CDN for single post purges, no more purge errors.

#### 3.5.38
* Adapted the action scheduler cron script to check active status of WooCommerce per site, not per network.
* Removed /favicon.ico from fast404 capability.
* Updated Servebolt Linux 8 users control panel link from top menu.
Expand Down
7 changes: 7 additions & 0 deletions Readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,13 @@ Yes, you can. The database optimizations are beneficial for everyone as well as
If you're a Servebolt client, please reach out to our Support Team and we'll be happy to help you out there. Alternatively, you can create a support forum request [here](https://wordpress.org/support/plugin/servebolt-optimizer/).

== Changelog ==

= 3.5.39 =
* Added sanitization to host calls for purging, and better validation, via update to Servebolt SDK.
* Made purge based AJAX error messages readable in the modal window.
* Reduced number of cache tags, removing ones that were never used.
* Adapted purge call for Servebolt CDN for single post purges, no more purge errors.

= 3.5.38 =
* Adapted the action scheduler cron script to check active status of WooCommerce per site, not per network.
* Removed /favicon.ico from fast404 capability.
Expand Down
31 changes: 17 additions & 14 deletions assets/src/js/cache-purge-trigger.js
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ jQuery(document).ready(function($) {
}, 100);
return;
}
window.sbCachePurgeError();
window.sbCachePurgeError('success but still a fail.');
// TODO: Display errors to the user
/*
if ( message ) {
Expand All @@ -380,7 +380,7 @@ jQuery(document).ready(function($) {
},
error: function() {
window.sb_loading(false);
window.sbCachePurgeError();
window.sbCachePurgeError('api error');
},
});
}
Expand Down Expand Up @@ -412,24 +412,27 @@ jQuery(document).ready(function($) {
window.update_cache_purge_list();
}, 100);
return;
}
window.sbCachePurgeError();
// TODO: Display errors to the user
/*
if ( message ) {
if ( response.data.type == 'warning' ) {
window.sb_warning(title, null, message);
} else {
if( Array.isArray(response.data) ) {
// Handle multiple messages
let output = '<details style="text-align:left;max-height:350px;overflow-y:auto"><summary style="text-align:center">review purge errors</summary><dl>';
for (let i = 0; i < response.data.length; i++) {
let message = (response.data[i].detail === null || response.data[i].detail === undefined) ? '' : response.data[i].detail;
output += "<dt>"+response.data[i].title + "</dt><dd>"+ message +" (code: "+ response.data[i].code +")</dd>";
}
output += '</dl></details>';
window.sbCachePurgeError(output, null, 'Purge API Errors');
} else {
window.sbCachePurgeError(message);
window.sbCachePurgeError(response.data, null, 'Purge API Error');
}
} else {
}
*/



},
error: function() {
window.sb_loading(false);
window.sbCachePurgeError();
window.sbCachePurgeError('post cache failed');
}
});
}
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"require": {
"php": "^7.3|^8.0",
"composer/installers": "^1.0",
"servebolt/sdk": "1.2.6"
"servebolt/sdk": "1.2.7"
},
"require-dev": {
"squizlabs/php_codesniffer": "*",
Expand Down
14 changes: 7 additions & 7 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion servebolt-optimizer.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/*
Plugin Name: Servebolt Optimizer
Version: 3.5.38
Version: 3.5.39
Author: Servebolt
Author URI: https://servebolt.com
Description: A plugin that implements Servebolt Security & Performance best practises for WordPress.
Expand Down
11 changes: 7 additions & 4 deletions src/Servebolt/CachePurge/Drivers/ServeboltCdn.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class ServeboltCdn implements CachePurgeAllInterface, CachePurgeTagInterface, Ca
*/
public function purgeByUrl(string $url): bool
{
$response = $this->apiInstance->environment()->purgeCdnCache(
$response = $this->apiInstance->environment()->purgeCache(
$this->apiInstance->getEnvironmentId(),
[$url]
);
Expand All @@ -44,7 +44,7 @@ public function purgeByUrl(string $url): bool
*/
public function purgeByUrls(array $urls): bool
{
$response = $this->apiInstance->environment->purgeCdnCache(
$response = $this->apiInstance->environment->purgeCache(
$this->apiInstance->getEnvironmentId(),
$urls
);
Expand All @@ -63,9 +63,12 @@ public function purgeByUrls(array $urls): bool
*/
public function purgeAll(): bool
{
$response = $this->apiInstance->environment->purgeCdnCache(
$response = $this->apiInstance->environment->purgeCache(
$this->apiInstance->getEnvironmentId(),
$this->getPurgeAllPrefixes()
[], // files
$this->getPurgeAllPrefixes() // prefixes
// tags
// hosts
);
if ($response->wasSuccessful()) {
return true;
Expand Down
2 changes: 1 addition & 1 deletion src/Servebolt/Helpers/Helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -811,7 +811,7 @@ function isNextGen($path = ''): bool
} else if (defined('ABSPATH')) {
$path = trailingslashit(dirname(ABSPATH));
} else {
throw new Exception('Could not determine default environment file folder path.');
throw new \Exception('Could not determine default environment file folder path.');
}
}
return ( strpos($path, '/cust/') === 0 ) ? true : false;
Expand Down
20 changes: 14 additions & 6 deletions tests/Unit/OptionsHelpersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,19 @@ public function testSmartAddOrUpdateBlogOptionsHelpers()
global $wpdb;
$optionsName = 'add-or-update';

global $wp_version;
$false = (version_compare($wp_version, '6.6.1', '<')) ? 'no' : 'off';
$true = (version_compare($wp_version, '6.6.1', '<')) ? 'yes' : 'auto';

$this->assertTrue(smartAddOrUpdateOption($site->blog_id, $optionsName, 'some-value'));
$this->assertEquals('no', $this->getOptionsAutoloadState($wpdb->options, getOptionName($optionsName)));
$this->assertEquals($false, $this->getOptionsAutoloadState($wpdb->options, getOptionName($optionsName)));

$this->assertTrue(smartAddOrUpdateOption($site->blog_id, $optionsName, 'some-other-value'));
$this->assertEquals('no', $this->getOptionsAutoloadState($wpdb->options, getOptionName($optionsName)));
$this->assertEquals($false, $this->getOptionsAutoloadState($wpdb->options, getOptionName($optionsName)));

$optionsName = 'add-or-update-2';
$this->assertTrue(smartUpdateOption($site->blog_id, $optionsName, 'some-value'));
$this->assertEquals('yes', $this->getOptionsAutoloadState($wpdb->options, getOptionName($optionsName)));
$this->assertEquals($true, $this->getOptionsAutoloadState($wpdb->options, getOptionName($optionsName)));
}, true);
}

Expand Down Expand Up @@ -229,16 +233,20 @@ public function testAddOrUpdateOptionsHelpers()
{
global $wpdb;
$optionsName = 'add-or-update';

global $wp_version;
$false = (version_compare($wp_version, '6.6.1', '<')) ? 'no' : 'off';
$true = (version_compare($wp_version, '6.6.1', '<')) ? 'yes' : 'auto';
$this->assertTrue(addOrUpdateOption($optionsName, 'some-value'));

$this->assertEquals('no', $this->getOptionsAutoloadState($wpdb->options, getOptionName($optionsName)));
$this->assertEquals($false, $this->getOptionsAutoloadState($wpdb->options, getOptionName($optionsName)));

$this->assertTrue(addOrUpdateOption($optionsName, 'some-other-value'));
$this->assertEquals('no', $this->getOptionsAutoloadState($wpdb->options, getOptionName($optionsName)));
$this->assertEquals($false, $this->getOptionsAutoloadState($wpdb->options, getOptionName($optionsName)));

$optionsName = 'add-or-update-2';
$this->assertTrue(updateOption($optionsName, 'some-value'));
$this->assertEquals('yes', $this->getOptionsAutoloadState($wpdb->options, getOptionName($optionsName)));
$this->assertEquals($true, $this->getOptionsAutoloadState($wpdb->options, getOptionName($optionsName)));
}

public function testThatWeCanSetADefaultOptionsValueWithFunctionClosure(): void
Expand Down

0 comments on commit 1074f81

Please sign in to comment.