From febc6df89c35ced32784e381dc8d251fd5bf0c1b Mon Sep 17 00:00:00 2001 From: Oliver Hader <oliver@typo3.org> Date: Mon, 29 Nov 2021 15:59:58 +0100 Subject: [PATCH] [!!!][TASK] Remove deprecated BackendUtility::viewOnClick Removes deprecated BackendUtility::viewOnClick, which should have been replaced with \TYPO3\CMS\Backend\Routing\PreviewUriBuilder. Resolves: #96141 Releases: main Change-Id: Iae391d10cba9880c23bf124e0905993fd315c405 Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/72376 Tested-by: Oliver Bartsch <bo@cedev.de> Tested-by: core-ci <typo3@b13.com> Tested-by: Benni Mack <benni@typo3.org> Reviewed-by: Oliver Bartsch <bo@cedev.de> Reviewed-by: Benni Mack <benni@typo3.org> --- .../Classes/Utility/BackendUtility.php | 48 ------------------- .../Utility/BackendUtilityTest.php | 46 ------------------ ...g-96107-DeprecatedFunctionalityRemoved.rst | 1 + .../Php/MethodCallStaticMatcher.php | 1 + 4 files changed, 2 insertions(+), 94 deletions(-) delete mode 100644 typo3/sysext/backend/Tests/UnitDeprecated/Utility/BackendUtilityTest.php diff --git a/typo3/sysext/backend/Classes/Utility/BackendUtility.php b/typo3/sysext/backend/Classes/Utility/BackendUtility.php index 338e2d6346b5..36421e9dcb95 100644 --- a/typo3/sysext/backend/Classes/Utility/BackendUtility.php +++ b/typo3/sysext/backend/Classes/Utility/BackendUtility.php @@ -2049,54 +2049,6 @@ class BackendUtility return ''; } - /** - * Returns a JavaScript string for viewing the page id, $id - * It will re-use any window already open. - * - * @param int $pageUid Page UID - * @param string $backPath Must point back to TYPO3_mainDir (where the site is assumed to be one level above) - * @param array|null $rootLine If root line is supplied the function will look for the first found domain record and use that URL instead (if found) - * @param string $anchorSection Optional anchor to the URL - * @param string $alternativeUrl An alternative URL that, if set, will ignore other parameters except $switchFocus: It will return the window.open command wrapped around this URL! - * @param string $additionalGetVars Additional GET variables. - * @param bool $switchFocus If TRUE, then the preview window will gain the focus. - * @return string - * @deprecated Use TYPO3\CMS\Backend\Routing\PreviewUriBuilder instead, will be removed in TYPO3 v12.0 - */ - public static function viewOnClick( - $pageUid, - $backPath = '', - $rootLine = null, - $anchorSection = '', - $alternativeUrl = '', - $additionalGetVars = '', - $switchFocus = true - ) { - trigger_error( - 'Using BackendUtility::viewOnClick() is deprecated, use TYPO3\CMS\Backend\Routing\PreviewUriBuilder instead.', - E_USER_DEPRECATED - ); - try { - $previewUrl = self::getPreviewUrl( - $pageUid, - $backPath, - $rootLine, - $anchorSection, - $alternativeUrl, - $additionalGetVars, - $switchFocus - ); - } catch (UnableToLinkToPageException $e) { - return ''; - } - - $onclickCode = 'var previewWin = window.open(' . GeneralUtility::quoteJSvalue($previewUrl) . ',\'newTYPO3frontendWindow\');' - . ($switchFocus ? 'previewWin.focus();' : '') . LF - . 'if (previewWin.location.href === ' . GeneralUtility::quoteJSvalue($previewUrl) . ') { previewWin.location.reload(); };'; - - return $onclickCode; - } - /** * Returns the preview url * diff --git a/typo3/sysext/backend/Tests/UnitDeprecated/Utility/BackendUtilityTest.php b/typo3/sysext/backend/Tests/UnitDeprecated/Utility/BackendUtilityTest.php deleted file mode 100644 index 3b7531f6abb2..000000000000 --- a/typo3/sysext/backend/Tests/UnitDeprecated/Utility/BackendUtilityTest.php +++ /dev/null @@ -1,46 +0,0 @@ -<?php - -declare(strict_types=1); - -/* - * This file is part of the TYPO3 CMS project. - * - * It is free software; you can redistribute it and/or modify it under - * the terms of the GNU General Public License, either version 2 - * of the License, or any later version. - * - * For the full copyright and license information, please read the - * LICENSE.txt file that was distributed with this source code. - * - * The TYPO3 project - inspiring people to share! - */ - -namespace TYPO3\CMS\Backend\Tests\UnitDeprecated\Utility; - -use TYPO3\CMS\Backend\Utility\BackendUtility; -use TYPO3\CMS\Core\Utility\GeneralUtility; -use TYPO3\TestingFramework\Core\Unit\UnitTestCase; - -/** - * Test case - */ -class BackendUtilityTest extends UnitTestCase -{ - /** - * @test - */ - public function viewOnClickReturnsOnClickCodeWithAlternativeUrl(): void - { - // Make sure the hook inside viewOnClick is not fired. This may be removed if unit tests - // bootstrap does not initialize TYPO3_CONF_VARS anymore. - unset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_befunc.php']['viewOnClickClass']); - - $alternativeUrl = 'https://typo3.org/about/typo3-the-cms/the-history-of-typo3/#section'; - $onclickCode = 'var previewWin = window.open(' . GeneralUtility::quoteJSvalue($alternativeUrl) . ',\'newTYPO3frontendWindow\');' . LF - . 'if (previewWin.location.href === ' . GeneralUtility::quoteJSvalue($alternativeUrl) . ') { previewWin.location.reload(); };'; - self::assertStringMatchesFormat( - $onclickCode, - BackendUtility::viewOnClick(null, null, null, null, $alternativeUrl, null, false) - ); - } -} diff --git a/typo3/sysext/core/Documentation/Changelog/12.0/Breaking-96107-DeprecatedFunctionalityRemoved.rst b/typo3/sysext/core/Documentation/Changelog/12.0/Breaking-96107-DeprecatedFunctionalityRemoved.rst index 679f97f0e4fa..50797ba0cece 100644 --- a/typo3/sysext/core/Documentation/Changelog/12.0/Breaking-96107-DeprecatedFunctionalityRemoved.rst +++ b/typo3/sysext/core/Documentation/Changelog/12.0/Breaking-96107-DeprecatedFunctionalityRemoved.rst @@ -43,6 +43,7 @@ The following PHP static class methods that have previously been marked as depre - :php:`\TYPO3\CMS\Backend\Utility\BackendUtility::fixVersioningPid()` - :php:`\TYPO3\CMS\Core\Utility\GeneralUtility::stdAuthCode()` +- :php:`\TYPO3\CMS\Backend\Utility\BackendUtility::viewOnClick` The following methods changed signature according to previous deprecations in v11 at the end of the argument list: diff --git a/typo3/sysext/install/Configuration/ExtensionScanner/Php/MethodCallStaticMatcher.php b/typo3/sysext/install/Configuration/ExtensionScanner/Php/MethodCallStaticMatcher.php index c782c9ac0bc0..5db349fe8c7c 100644 --- a/typo3/sysext/install/Configuration/ExtensionScanner/Php/MethodCallStaticMatcher.php +++ b/typo3/sysext/install/Configuration/ExtensionScanner/Php/MethodCallStaticMatcher.php @@ -939,6 +939,7 @@ return [ 'restFiles' => [ 'Important-91123-AvoidUsingBackendUtilityViewOnClick.rst', 'Deprecation-91806-BackendUtilityViewOnClick.rst', + 'Breaking-96107-DeprecatedFunctionalityRemoved.rst', ], ], 'TYPO3\CMS\Core\Utility\GeneralUtility::getApplicationContext' => [ -- GitLab