diff --git a/src/Handling/SpellCheckAdminExtension.php b/src/Handling/SpellCheckAdminExtension.php index fc79f6c..1c7fb78 100644 --- a/src/Handling/SpellCheckAdminExtension.php +++ b/src/Handling/SpellCheckAdminExtension.php @@ -5,6 +5,7 @@ use SilverStripe\Control\Director; use SilverStripe\Core\Config\Configurable; use SilverStripe\Core\Extension; +use SilverStripe\Dev\Deprecation; use SilverStripe\Forms\HTMLEditor\TinyMCEConfig; use SilverStripe\i18n\i18n; use SilverStripe\Security\SecurityToken; @@ -27,8 +28,10 @@ class SpellCheckAdminExtension extends Extension public function init() { // Set settings (respect deprecated middleware) - $editor = SpellCheckMiddleware::config()->get('editor') - ?: static::config()->get('editor'); + $middlewareConfig = Deprecation::withNoReplacement(function () { + return SpellCheckMiddleware::config()->get('editor'); + }); + $editor = $middlewareConfig ?: static::config()->get('editor'); /** @var TinyMCEConfig $editorConfig */ $editorConfig = TinyMCEConfig::get($editor); diff --git a/src/Handling/SpellController.php b/src/Handling/SpellController.php index d7874b8..3ee5fa2 100644 --- a/src/Handling/SpellController.php +++ b/src/Handling/SpellController.php @@ -9,6 +9,7 @@ use SilverStripe\SpellCheck\Data\SpellProvider; use SilverStripe\Security\Permission; use SilverStripe\Security\SecurityToken; +use SilverStripe\Control\Middleware\HTTPCacheControlMiddleware; /** * Controller to handle requests for spellchecking @@ -245,8 +246,7 @@ protected function assembleData($locale, $words) protected function setHeaders() { // Set headers - HTTP::set_cache_age(0); - HTTP::add_cache_headers($this->response); + HTTPCacheControlMiddleware::singleton()->setMaxAge(0); $this->response ->addHeader('Content-Type', 'application/json') ->addHeader('Content-Encoding', 'UTF-8') diff --git a/tests/Handling/SpellCheckMiddlewareTest.php b/tests/Handling/SpellCheckMiddlewareTest.php index 5dc4207..9817fc1 100644 --- a/tests/Handling/SpellCheckMiddlewareTest.php +++ b/tests/Handling/SpellCheckMiddlewareTest.php @@ -6,11 +6,15 @@ use SilverStripe\Dev\SapphireTest; use SilverStripe\SpellCheck\Handling\SpellCheckMiddleware; use SilverStripe\SpellCheck\Handling\SpellController; +use SilverStripe\Dev\Deprecation; class SpellCheckMiddlewareTest extends SapphireTest { public function testGetDefaultLocale() { + if (Deprecation::isEnabled()) { + $this->markTestSkipped('Test calls deprecated code'); + } $middleware = new SpellCheckMiddleware(); Config::modify()->set(SpellController::class, 'default_locale', 'foo');