diff --git a/typo3/sysext/core/Classes/Core/Environment.php b/typo3/sysext/core/Classes/Core/Environment.php index c065df09e6c3457cd56a324ff522c04dff11fe9f..4ee7e21d9d39b0412d0636c6c46afdb891e76b6d 100644 --- a/typo3/sysext/core/Classes/Core/Environment.php +++ b/typo3/sysext/core/Classes/Core/Environment.php @@ -252,9 +252,11 @@ class Environment /** * Previously known as PATH_typo3 * Please note that this might be gone at some point + * @deprecated you should not rely on this method, as the backend path might change. */ public static function getBackendPath(): string { + trigger_error('Environment::getBackendPath() will be removed in TYPO3 v13.0.', E_USER_DEPRECATED); return self::getPublicPath() . '/typo3'; } diff --git a/typo3/sysext/core/Documentation/Changelog/12.2/Deprecation-99638-EnvironmentgetBackendPath.rst b/typo3/sysext/core/Documentation/Changelog/12.2/Deprecation-99638-EnvironmentgetBackendPath.rst new file mode 100644 index 0000000000000000000000000000000000000000..fed6bf59dbc073f38bfed7d779b6b23b0dcf6c5c --- /dev/null +++ b/typo3/sysext/core/Documentation/Changelog/12.2/Deprecation-99638-EnvironmentgetBackendPath.rst @@ -0,0 +1,41 @@ +.. include:: /Includes.rst.txt + +.. _deprecation-99638-1674127318: + +=================================================== +Deprecation: #99638 - Environment::getBackendPath() +=================================================== + +See :issue:`99638` + +Description +=========== + +TYPO3's Backend path "/typo3" is currently resolved statically in :php:`Environment::getBackendPath()` to return the full path to the backend entrypoint. + +However, as TYPO3's code base is evolving, the usages to the hardcoded path have been reduced +and the functionality is now migrated into a new :php:`BackendEntryPointResolver` class, +which allows for dynamically adjusting the entry point in the future. + + +Impact +====== + +Calling the method will trigger a PHP deprecation warning. + + +Affected installations +====================== + +TYPO3 installations with custom extensions using the method in PHP code. + + +Migration +========= + +Check for the extension scanner, and see if the code is necessary, or if any alternative, +such as the :php:`BackendEntryPointResolver` or :php:`NormalizedParams` might be better +suited as third-party extensions should not rely on the hard-coded paths to resources from +:file:`typo3/*` anymore. + +.. index:: PHP-API, FullyScanned, ext:core \ No newline at end of file diff --git a/typo3/sysext/core/Tests/Unit/Utility/GeneralUtilityTest.php b/typo3/sysext/core/Tests/Unit/Utility/GeneralUtilityTest.php index 370284c9c40b2f2a4c5e014775b6df9935215553..3497cdd642b144ca998ca57ab4163a31f9248bfa 100644 --- a/typo3/sysext/core/Tests/Unit/Utility/GeneralUtilityTest.php +++ b/typo3/sysext/core/Tests/Unit/Utility/GeneralUtilityTest.php @@ -1419,7 +1419,8 @@ class GeneralUtilityTest extends UnitTestCase Environment::getPublicPath(), Environment::getVarPath(), Environment::getConfigPath(), - Environment::getBackendPath() . '/index.php', + // needs to be a subpath in order to validate ".." references + Environment::getPublicPath() . '/typo3/index.php', Environment::isWindows() ? 'WINDOWS' : 'UNIX' ); self::assertEquals($path, GeneralUtility::sanitizeLocalUrl($path)); @@ -1439,7 +1440,8 @@ class GeneralUtilityTest extends UnitTestCase Environment::getPublicPath(), Environment::getVarPath(), Environment::getConfigPath(), - Environment::getBackendPath() . '/index.php', + // needs to be a subpath in order to validate ".." references + Environment::getPublicPath() . '/typo3/index.php', Environment::isWindows() ? 'WINDOWS' : 'UNIX' ); self::assertEquals(rawurlencode($path), GeneralUtility::sanitizeLocalUrl(rawurlencode($path))); @@ -1490,7 +1492,8 @@ class GeneralUtilityTest extends UnitTestCase Environment::getPublicPath(), Environment::getVarPath(), Environment::getConfigPath(), - Environment::getBackendPath() . '/index.php', + // needs to be a subpath in order to validate ".." references + Environment::getPublicPath() . '/typo3/index.php', Environment::isWindows() ? 'WINDOWS' : 'UNIX' ); $_SERVER['HTTP_HOST'] = $host; @@ -1512,7 +1515,8 @@ class GeneralUtilityTest extends UnitTestCase Environment::getPublicPath(), Environment::getVarPath(), Environment::getConfigPath(), - Environment::getBackendPath() . '/index.php', + // needs to be a subpath in order to validate ".." references + Environment::getPublicPath() . '/typo3/index.php', Environment::isWindows() ? 'WINDOWS' : 'UNIX' ); $_SERVER['HTTP_HOST'] = $host; @@ -1553,7 +1557,7 @@ class GeneralUtilityTest extends UnitTestCase Environment::getPublicPath(), Environment::getVarPath(), Environment::getConfigPath(), - Environment::getBackendPath() . '/index.php', + Environment::getPublicPath() . '/typo3/index.php', Environment::isWindows() ? 'WINDOWS' : 'UNIX' ); $_SERVER['HTTP_HOST'] = 'localhost'; diff --git a/typo3/sysext/install/Configuration/ExtensionScanner/Php/MethodCallStaticMatcher.php b/typo3/sysext/install/Configuration/ExtensionScanner/Php/MethodCallStaticMatcher.php index f501ea80323195e38a5fda7fa5ce950a3efb397b..68c1d49742b69de7ae133f4a5f335605b4747a5c 100644 --- a/typo3/sysext/install/Configuration/ExtensionScanner/Php/MethodCallStaticMatcher.php +++ b/typo3/sysext/install/Configuration/ExtensionScanner/Php/MethodCallStaticMatcher.php @@ -1443,11 +1443,18 @@ return [ 'Deprecation-99579-BackendUtilityGetFuncCheck.rst', ], ], - 'TYPO3\CMS\Backend\Utility\GeneralUtility::_GPmerged' => [ + 'TYPO3\CMS\Core\Utility\GeneralUtility::_GPmerged' => [ 'numberOfMandatoryArguments' => 1, 'maximumNumberOfArguments' => 1, 'restFiles' => [ 'Deprecation-99615-GeneralUtilityGPMerged.rst', ], ], + 'TYPO3\CMS\Core\Core\Environment::getBackendPath' => [ + 'numberOfMandatoryArguments' => 0, + 'maximumNumberOfArguments' => 0, + 'restFiles' => [ + 'Deprecation-99638-EnvironmentgetBackendPath.rst', + ], + ], ];