Deprecation: #100597 - BackendUtility methods getThumbnailUrl() and getLinkToDataHandlerAction()

See forge#100597

Description

The methods \TYPO3\CMS\Backend\Utility\BackendUtility::getThumbnailUrl() and \TYPO3\CMS\Backend\Utility\BackendUtility::getLinkToDataHandlerAction() have been marked as deprecated.

Impact

Calling those methods will trigger a PHP deprecation level log warning.

Affected installations

TYPO3 installations with custom extensions using those methods. The extension scanner will report usages as strong match.

Migration

Instead of calling BackendUtility::getThumbnailUrl(), inject and use the \TYPO3\CMS\Core\Resource\ResourceFactory directly:

// before
$url = BackendUtility::getThumbnailUrl(2004, [
    'width' => 20,
    'height' => 13,
    '_context' => ProcessedFile::CONTEXT_IMAGEPREVIEW
]);

// after
$url = $this->resourceFactory
    ->getFileObject(2004)
    ->process(ProcessedFile::CONTEXT_IMAGEPREVIEW, ['width' => 20, 'height' => 13])
    ->getPublicUrl();
Copied!

Instead of calling BackendUtility::getLinkToDataHandlerAction(), inject and use the \TYPO3\CMS\Backend\Routing\UriBuilder directly:

// before
$url = BackendUtility::getLinkToDataHandlerAction(
    '&cmd[pages][123][localize]=10',
    (string)$uriBuilder->buildUriFromRoute('some_route')
);

// after
$url = (string)$this->uriBuilder->buildUriFromRoute(
    'tce_db',
    [
        'cmd' => [
            'pages' => [
                123 => [
                    'localize' => 10,
                ],
            ],
        ],
        'redirect' => (string)$uriBuilder->buildUriFromRoute('some_route'),
    ]
);
Copied!

In case the second paramter $redirectUrl was omitted, getLinkToDataHandlerAction automatically used the current request URI as the return URL. In case you relied on this, make sure the redirect parameter is set to $request->getAttribute('normalizedParams')->getRequestUri().