Skip to content

Commit

Permalink
ENH Suppress deprecation notices for API we can't avoid
Browse files Browse the repository at this point in the history
  • Loading branch information
GuySartorelli committed Oct 10, 2024
1 parent 6b6fcbc commit 1cbdd66
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/Shortcodes/FileShortcodeProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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));

Expand Down
4 changes: 3 additions & 1 deletion tests/php/ImageManipulationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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) ?? '')
);
}

Expand Down

0 comments on commit 1cbdd66

Please sign in to comment.