From f9390a7b53fac9c7b67bf6f5bc34e2656ba47cab Mon Sep 17 00:00:00 2001 From: Guy Sartorelli Date: Thu, 10 Oct 2024 16:38:43 +1300 Subject: [PATCH] ENH Suppress deprecation notices for API we can't avoid --- src/Shortcodes/FileShortcodeProvider.php | 3 ++- tests/php/ImageManipulationTest.php | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Shortcodes/FileShortcodeProvider.php b/src/Shortcodes/FileShortcodeProvider.php index 311abf42..8b78b17b 100644 --- a/src/Shortcodes/FileShortcodeProvider.php +++ b/src/Shortcodes/FileShortcodeProvider.php @@ -12,6 +12,7 @@ use SilverStripe\Core\Flushable; use SilverStripe\Core\Injector\Injectable; use SilverStripe\Core\Injector\Injector; +use SilverStripe\Dev\Deprecation; use SilverStripe\ErrorPage\ErrorPage; use SilverStripe\ORM\DataObject; use SilverStripe\View\ArrayData; @@ -238,7 +239,7 @@ protected static function find_error_record($errorCode) public static function getCacheKey($params, $content = null) { $key = SSViewer::config()->get('global_key'); - $viewer = new SSViewer_FromString($key); + $viewer = Deprecation::withSuppressedNotice(fn() => new SSViewer_FromString($key)); $globalKey = md5($viewer->process(ArrayData::create([])) ?? ''); $argsKey = md5(serialize($params)) . '#' . md5(serialize($content)); diff --git a/tests/php/ImageManipulationTest.php b/tests/php/ImageManipulationTest.php index c872f113..61092505 100644 --- a/tests/php/ImageManipulationTest.php +++ b/tests/php/ImageManipulationTest.php @@ -21,6 +21,7 @@ use SilverStripe\Assets\Tests\ImageManipulationTest\LazyLoadAccessorExtension; use SilverStripe\Core\Config\Config; use SilverStripe\Core\Injector\Injector; +use SilverStripe\Dev\Deprecation; use SilverStripe\Dev\SapphireTest; use SilverStripe\View\SSViewer; @@ -449,9 +450,10 @@ public function testRender(string $template, string $expected) /** @var Image $origin */ $image = $this->objFromFixture(Image::class, 'imageWithTitle'); + $fromString = Deprecation::withSuppressedNotice(fn() => SSViewer::fromString($template)); $this->assertEquals( $expected, - trim($image->renderWith(SSViewer::fromString($template)) ?? '') + trim($image->renderWith($fromString) ?? '') ); }