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

ENH Suppress deprecation notices for API we can't avoid #649

Closed
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
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