From cd55808b1ac40b943f12fa07277fdef73651ac11 Mon Sep 17 00:00:00 2001 From: Christian Kuhn <lolli@schwarzbu.ch> Date: Wed, 19 Dec 2018 01:24:48 +0100 Subject: [PATCH] [!!!][TASK] Remove deprecated methods from BackendUtility Removes most deprecated code from BackendUtility, except a method that has bigger cross dependencies to other deprecated code. Removed methods: TYPO3\CMS\Backend\Utility\BackendUtility::deleteClause() TYPO3\CMS\Backend\Utility\BackendUtility::getOriginalTranslationTable() TYPO3\CMS\Backend\Utility\BackendUtility::getTCAtypes() TYPO3\CMS\Backend\Utility\BackendUtility::storeHash() TYPO3\CMS\Backend\Utility\BackendUtility::getHash() TYPO3\CMS\Backend\Utility\BackendUtility::getListGroupNames() TYPO3\CMS\Backend\Utility\BackendUtility::getModTSconfig() TYPO3\CMS\Backend\Utility\BackendUtility::unsetMenuItems() TYPO3\CMS\Backend\Utility\BackendUtility::getModuleUrl() TYPO3\CMS\Backend\Utility\BackendUtility::getPidForModTSconfig() TYPO3\CMS\Backend\Utility\BackendUtility::getDomainStartPage() TYPO3\CMS\Backend\Utility\BackendUtility::shortcutExists() Method signatures: TYPO3\CMS\Backend\Utility\BackendUtility::getPagesTSconfig() - Second and third argument dropped Other notes: Overriding page TSconfig on user TSconfig level with the 'mod.' prefix is dropped, used 'page.mod' instead. Resolves: #87206 Releases: master Change-Id: Ib4102bfc24a99a22891deb46d4b1bb227ffd3936 Reviewed-on: https://review.typo3.org/59203 Tested-by: TYPO3com <no-reply@typo3.com> Reviewed-by: Benni Mack <benni@typo3.org> Tested-by: Benni Mack <benni@typo3.org> Reviewed-by: Georg Ringer <georg.ringer@gmail.com> Tested-by: Georg Ringer <georg.ringer@gmail.com> --- .../Classes/Utility/BackendUtility.php | 417 +----------------- .../Utility/BackendUtilityTest.php | 309 ------------- .../Fixtures/BackendUtilityFixture.php | 34 -- ...g-87193-DeprecatedFunctionalityRemoved.rst | 24 + .../Unit/Service/FlexFormServiceTest.php | 3 +- .../Unit/Mvc/Web/Routing/UriBuilderTest.php | 5 - .../MethodArgumentDroppedStaticMatcher.php | 1 + .../Php/MethodCallStaticMatcher.php | 12 + 8 files changed, 54 insertions(+), 751 deletions(-) delete mode 100644 typo3/sysext/backend/Tests/UnitDeprecated/Utility/BackendUtilityTest.php delete mode 100644 typo3/sysext/backend/Tests/UnitDeprecated/Utility/Fixtures/BackendUtilityFixture.php diff --git a/typo3/sysext/backend/Classes/Utility/BackendUtility.php b/typo3/sysext/backend/Classes/Utility/BackendUtility.php index 1e8a0df92a54..1723ab4b73df 100644 --- a/typo3/sysext/backend/Classes/Utility/BackendUtility.php +++ b/typo3/sysext/backend/Classes/Utility/BackendUtility.php @@ -15,7 +15,7 @@ namespace TYPO3\CMS\Backend\Utility; */ use Psr\Log\LoggerInterface; -use TYPO3\CMS\Backend\Backend\Shortcut\ShortcutRepository; +use TYPO3\CMS\Backend\Configuration\TsConfigParser; use TYPO3\CMS\Backend\Routing\UriBuilder; use TYPO3\CMS\Core\Authentication\BackendUserAuthentication; use TYPO3\CMS\Core\Cache\CacheManager; @@ -69,50 +69,11 @@ use TYPO3\CMS\Frontend\Page\PageRepository; */ class BackendUtility { - /** - * Cache the TCA configuration of tables with their types during runtime - * - * @var array - * @see self::getTCAtypes() - * @deprecated since TYPO3 v9.4 will be removed in TYPO3 v10.0. - */ - protected static $tcaTableTypeConfigurationCache = []; - /******************************************* * * SQL-related, selecting records, searching * *******************************************/ - /** - * Returns the WHERE clause " AND NOT [tablename].[deleted-field]" if a deleted-field - * is configured in $GLOBALS['TCA'] for the tablename, $table - * This function should ALWAYS be called in the backend for selection on tables which - * are configured in $GLOBALS['TCA'] since it will ensure consistent selection of records, - * even if they are marked deleted (in which case the system must always treat them as non-existent!) - * In the frontend a function, ->enableFields(), is known to filter hidden-field, start- and endtime - * and fe_groups as well. But that is a job of the frontend, not the backend. If you need filtering - * on those fields as well in the backend you can use ->BEenableFields() though. - * - * @param string $table Table name present in $GLOBALS['TCA'] - * @param string $tableAlias Table alias if any - * @return string WHERE clause for filtering out deleted records, eg " AND tablename.deleted=0 - * @deprecated since TYPO3 v9, will be removed in TYPO3 v10.0, the DeletedRestriction functionality should be used instead. - */ - public static function deleteClause($table, $tableAlias = '') - { - trigger_error('BackendUtility::deleteClause() will be removed in TYPO3 v10.0. Add the delete statement directly in your SQL statement via the DeletedRestriction.', E_USER_DEPRECATED); - if (empty($GLOBALS['TCA'][$table]['ctrl']['delete'])) { - return ''; - } - $expressionBuilder = GeneralUtility::makeInstance(ConnectionPool::class) - ->getQueryBuilderForTable($table) - ->expr(); - return ' AND ' . $expressionBuilder->eq( - ($tableAlias ?: $table) . '.' . $GLOBALS['TCA'][$table]['ctrl']['delete'], - 0 - ); - } - /** * Gets record with uid = $uid from $table * You can set $field to a list of fields (default is '*') @@ -584,18 +545,6 @@ class BackendUtility return $output; } - /** - * Gets the original translation pointer table, which is always the same table - * - * @param string $table Name of the table - * @return string Pointer table (if any) - */ - public static function getOriginalTranslationTable($table) - { - trigger_error('Starting with TYPO3 v9, the translation table is always the same as the original table, because pages_language_overlay has been migrated into pages table.', E_USER_DEPRECATED); - return $table; - } - /** * Determines whether a table is localizable and has the languageField and transOrigPointerField set in $GLOBALS['TCA']. * @@ -644,91 +593,6 @@ class BackendUtility return false; } - /** - * Returns the "types" configuration parsed into an array for the record, $rec, from table, $table - * - * @param string $table Table name (present in TCA) - * @param array $rec Record from $table - * @param bool $useFieldNameAsKey If $useFieldNameAsKey is set, then the fieldname is associative keys in the return array, otherwise just numeric keys. - * @return array|null - * @deprecated since TYPO3 v9.4 will be removed in TYPO3 v10.0. - */ - public static function getTCAtypes($table, $rec, $useFieldNameAsKey = false) - { - trigger_error('BackendUtility::getTCAtypes() will be removed in TYPO3 v10.0. The method is not in use anymore.', E_USER_DEPRECATED); - if (isset($GLOBALS['TCA'][$table])) { - // Get type value: - $fieldValue = self::getTCAtypeValue($table, $rec); - $cacheIdentifier = $table . '-type-' . $fieldValue . '-fnk-' . $useFieldNameAsKey; - - // Fetch from first-level-cache if available - if (isset(self::$tcaTableTypeConfigurationCache[$cacheIdentifier])) { - return self::$tcaTableTypeConfigurationCache[$cacheIdentifier]; - } - - // Get typesConf - $typesConf = $GLOBALS['TCA'][$table]['types'][$fieldValue] ?? null; - // Get fields list and traverse it - $fieldList = explode(',', $typesConf['showitem']); - - // Add subtype fields e.g. for a valid RTE transformation - // The RTE runs the DB -> RTE transformation only, if the RTE field is part of the getTCAtypes array - if (isset($typesConf['subtype_value_field'])) { - $subType = $rec[$typesConf['subtype_value_field']]; - if (isset($typesConf['subtypes_addlist'][$subType])) { - $subFields = GeneralUtility::trimExplode(',', $typesConf['subtypes_addlist'][$subType], true); - $fieldList = array_merge($fieldList, $subFields); - } - } - - // Add palette fields e.g. for a valid RTE transformation - $paletteFieldList = []; - foreach ($fieldList as $fieldData) { - $fieldDataArray = GeneralUtility::trimExplode(';', $fieldData); - // first two entries would be fieldname and altTitle, they are not used here. - $pPalette = $fieldDataArray[2] ?? null; - if ($pPalette - && isset($GLOBALS['TCA'][$table]['palettes'][$pPalette]) - && is_array($GLOBALS['TCA'][$table]['palettes'][$pPalette]) - && isset($GLOBALS['TCA'][$table]['palettes'][$pPalette]['showitem']) - ) { - $paletteFields = GeneralUtility::trimExplode(',', $GLOBALS['TCA'][$table]['palettes'][$pPalette]['showitem'], true); - foreach ($paletteFields as $paletteField) { - if ($paletteField !== '--linebreak--') { - $paletteFieldList[] = $paletteField; - } - } - } - } - $fieldList = array_merge($fieldList, $paletteFieldList); - $altFieldList = []; - // Traverse fields in types config and parse the configuration into a nice array: - foreach ($fieldList as $k => $v) { - $vArray = GeneralUtility::trimExplode(';', $v); - $fieldList[$k] = [ - 'field' => $vArray[0], - 'title' => $vArray[1] ?? null, - 'palette' => $vArray[2] ?? null, - 'spec' => [], - 'origString' => $v - ]; - if ($useFieldNameAsKey) { - $altFieldList[$fieldList[$k]['field']] = $fieldList[$k]; - } - } - if ($useFieldNameAsKey) { - $fieldList = $altFieldList; - } - - // Add to first-level-cache - self::$tcaTableTypeConfigurationCache[$cacheIdentifier] = $fieldList; - - // Return array: - return $fieldList; - } - return null; - } - /** * Returns the "type" value of $rec from $table which can be used to look up the correct "types" rendering section in $GLOBALS['TCA'] * If no "type" field is configured in the "ctrl"-section of the $GLOBALS['TCA'] for the table, zero is used. @@ -795,47 +659,6 @@ class BackendUtility return $typeNum; } - /******************************************* - * - * Caching related - * - *******************************************/ - /** - * Stores $data in the 'cache_hash' cache with the hash key, $hash - * and visual/symbolic identification, $ident - * - * @param string $hash 32 bit hash string (eg. a md5 hash of a serialized array identifying the data being stored) - * @param mixed $data The data to store - * @param string $ident $ident is just a textual identification in order to inform about the content! - * @deprecated since TYPO3 v9, will be removed in TYPO3 v10.0, use the Caching Framework directly - */ - public static function storeHash($hash, $data, $ident) - { - trigger_error('BackendUtility::storeHash() will be removed in TYPO3 v10.0, use the Caching Framework directly.', E_USER_DEPRECATED); - $cacheManager = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Cache\CacheManager::class); - $cacheManager->getCache('cache_hash')->set($hash, $data, ['ident_' . $ident], 0); - } - - /** - * Returns data stored for the hash string in the cache "cache_hash" - * Can be used to retrieved a cached value, array or object - * - * @param string $hash The hash-string which was used to store the data value - * @return mixed The "data" from the cache - * @deprecated since TYPO3 v9, will be removed in TYPO3 v10.0, use the Caching Framework directly - */ - public static function getHash($hash) - { - trigger_error('BackendUtility::getHash() will be removed in TYPO3 v10.0, use the Caching Framework directly.', E_USER_DEPRECATED); - $cacheManager = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Cache\CacheManager::class); - $cacheEntry = $cacheManager->getCache('cache_hash')->get($hash); - $hashContent = null; - if ($cacheEntry) { - $hashContent = $cacheEntry; - } - return $hashContent; - } - /******************************************* * * TypoScript related @@ -845,82 +668,49 @@ class BackendUtility * Returns the Page TSconfig for page with id, $id * * @param int $id Page uid for which to create Page TSconfig - * @param array $rootLine @deprecated - * @param bool $returnPartArray @deprecated * @return array Page TSconfig * @see \TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser */ - public static function getPagesTSconfig($id, $rootLine = null, $returnPartArray = false) + public static function getPagesTSconfig($id) { $id = (int)$id; $cache = self::getRuntimeCache(); - if ($returnPartArray === false - && $rootLine === null - && $cache->has('pagesTsConfigIdToHash' . $id) - ) { + if ($cache->has('pagesTsConfigIdToHash' . $id)) { return $cache->get('pagesTsConfigHashToContent' . $cache->get('pagesTsConfigIdToHash' . $id)); } - $tsConfig = []; - // No custom rootline, so the results can be cached - if (!is_array($rootLine)) { - $rootLine = self::BEgetRootLine($id, '', true); - $useCacheForCurrentPageId = true; - } else { - trigger_error('Calling BackendUtility::getPagesTSconfig() with a custom rootline handed over as second argument will be removed in TYPO3 v10.0. Use TYPO3\CMS\Backend\Utility\BackendUtility::getRawPagesTSconfig() instead and parse PageTS yourself.', E_USER_DEPRECATED); - $useCacheForCurrentPageId = false; - } + $tsConfig = []; + $rootLine = self::BEgetRootLine($id, '', true); $TSdataArray = static::getRawPagesTSconfig($id, $rootLine); - if ($returnPartArray) { - trigger_error('Calling BackendUtility::getPagesTSconfig() with a third parameter to return the unparsed array directly will be removed in TYPO3 v10.0. Use TYPO3\CMS\Backend\Utility\BackendUtility::getRawPagesTSconfig() instead.', E_USER_DEPRECATED); - return $TSdataArray; - } + // Parsing the page TS-Config $pageTs = implode(LF . '[GLOBAL]' . LF, $TSdataArray); - /* @var \TYPO3\CMS\Backend\Configuration\TsConfigParser $parseObj */ - $parseObj = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Configuration\TsConfigParser::class); + $parseObj = GeneralUtility::makeInstance(TsConfigParser::class); $res = $parseObj->parseTSconfig($pageTs, 'PAGES', $id, $rootLine); if ($res) { $tsConfig = $res['TSconfig']; } $cacheHash = $res['hash']; + // Get User TSconfig overlay, if no backend user is logged-in, this needs to be checked as well if (static::getBackendUserAuthentication()) { $userTSconfig = static::getBackendUserAuthentication()->getTSConfig() ?? []; } else { $userTSconfig = []; } - $isCacheHashExtendedWithUserUid = false; + if (is_array($userTSconfig['page.'] ?? null)) { + // Override page TSconfig with user TSconfig ArrayUtility::mergeRecursiveWithOverrule($tsConfig, $userTSconfig['page.']); - $isCacheHashExtendedWithUserUid = true; $cacheHash .= '_user' . static::getBackendUserAuthentication()->user['uid']; } - // Overlay page "mod." ts with user ts in a special and deprecated way - if (is_array($userTSconfig['mod.'] ?? null)) { - // @deprecated This entire "if" and variable $isCacheHashExtendedWithUserUid can be deleted in TYPO3 v10.0 - trigger_error( - 'Overriding page TSconfig "mod." with user TSconfig "mod." is deprecated. Use user TSconfig "page.mod." instead.', - E_USER_DEPRECATED - ); - if (!is_array($tsConfig['mod.'])) { - $tsConfig['mod.'] = []; - } - ArrayUtility::mergeRecursiveWithOverrule($tsConfig['mod.'], $userTSconfig['mod.']); - if (!$isCacheHashExtendedWithUserUid) { - $cacheHash .= '_user' . static::getBackendUserAuthentication()->user['uid']; - } - } - - if ($useCacheForCurrentPageId) { - // Many pages end up with the same ts config. To reduce memory usage, the cache - // entries are a linked list: One or more pids point to content hashes which then - // contain the cached content. - $cache->set('pagesTsConfigHashToContent' . $cacheHash, $tsConfig, ['pagesTsConfig']); - $cache->set('pagesTsConfigIdToHash' . $id, $cacheHash, ['pagesTsConfig']); - } + // Many pages end up with the same ts config. To reduce memory usage, the cache + // entries are a linked list: One or more pids point to content hashes which then + // contain the cached content. + $cache->set('pagesTsConfigHashToContent' . $cacheHash, $tsConfig, ['pagesTsConfig']); + $cache->set('pagesTsConfigIdToHash' . $id, $cacheHash, ['pagesTsConfig']); return $tsConfig; } @@ -1060,25 +850,6 @@ class BackendUtility return ArrayUtility::sortArraysByKey($result, $titleField); } - /** - * Returns an array with be_groups records (like ->getGroupNames) but: - * - if the current BE_USER is admin, then all groups are returned, otherwise only groups that the current user is member of (usergroup_cached_list) will be returned. - * - * @param string $fields Field list; $fields specify the fields selected (default: title,uid) - * @return array - * @deprecated since TYPO3 v9, will be removed in TYPO3 v10.0. - */ - public static function getListGroupNames($fields = 'title, uid') - { - trigger_error('BackendUtility::getListGroupNames() will be removed in TYPO3 v10.0, you should generate the list of backend user groups by yourself.', E_USER_DEPRECATED); - $beUser = static::getBackendUserAuthentication(); - $exQ = ''; - if (!$beUser->isAdmin()) { - $exQ = ' AND uid IN (' . ($beUser->user['usergroup_cached_list'] ?: 0) . ')'; - } - return self::getGroupNames($fields, $exQ); - } - /** * Returns the array $usernames with the names of all users NOT IN $groupArray changed to the uid (hides the usernames!). * If $excludeBlindedFlag is set, then these records are unset from the array $usernames @@ -2770,7 +2541,7 @@ class BackendUtility * * @param string $parameters Set of GET params to send. Example: "&cmd[tt_content][123][move]=456" or "&data[tt_content][123][hidden]=1&data[tt_content][123][title]=Hello%20World * @param string|int $redirectUrl Redirect URL, default is to use GeneralUtility::getIndpEnv('REQUEST_URI'), -1 means to generate an URL for JavaScript using T3_THIS_LOCATION - * @return string URL to BackendUtility::getModuleUrl('tce_db') + parameters + * @return string */ public static function getLinkToDataHandlerAction($parameters, $redirectUrl = '') { @@ -2900,32 +2671,6 @@ class BackendUtility return $domain; } - /** - * Returns the merged User/Page TSconfig for page id, $id. - * Please read details about module programming elsewhere! - * - * @param int $id Page uid - * @param string $TSref An object string which determines the path of the TSconfig to return. - * @return array - * @deprecated since TYPO3 v9, will be removed in TYPO3 v10.0, use getPagesTSconfig() instead - */ - public static function getModTSconfig($id, $TSref) - { - trigger_error( - 'BackendUtility::getModTSconfig() will be removed in TYPO3 v10.0.' - . ' Use BackendUtility::getPagesTSconfig() to retrieve the full page TSconfig array instead.', - E_USER_DEPRECATED - ); - $beUser = static::getBackendUserAuthentication(); - $pageTS_modOptions = $beUser->getTSConfig($TSref, static::getPagesTSconfig($id)); - $BE_USER_modOptions = $beUser->getTSConfig($TSref); - if ($BE_USER_modOptions['value'] === null) { - unset($BE_USER_modOptions['value']); - } - ArrayUtility::mergeRecursiveWithOverrule($pageTS_modOptions, $BE_USER_modOptions); - return $pageTS_modOptions; - } - /** * Returns a selector box "function menu" for a module * Requires the JS function jumpToUrl() to be available @@ -3115,31 +2860,6 @@ class BackendUtility return $scriptUrl; } - /** - * Removes menu items from $itemArray if they are configured to be removed by TSconfig for the module ($modTSconfig) - * See Inside TYPO3 about how to program modules and use this API. - * - * @param array $modTSconfig Module TS config array - * @param array $itemArray Array of items from which to remove items. - * @param string $TSref $TSref points to the "object string" in $modTSconfig - * @return array The modified $itemArray is returned. - * @deprecated since TYPO3 v9, will be removed with TYPO3 v10.0 - */ - public static function unsetMenuItems($modTSconfig, $itemArray, $TSref) - { - trigger_error('BackendUtility::getPidForModTSconfig() will be removed in TYPO3 v10.0.', E_USER_DEPRECATED); - // Getting TS-config options for this module for the Backend User: - $conf = static::getBackendUserAuthentication()->getTSConfig($TSref, $modTSconfig); - if (is_array($conf['properties'])) { - foreach ($conf['properties'] as $key => $val) { - if (!$val) { - unset($itemArray[$key]); - } - } - } - return $itemArray; - } - /** * Call to update the page tree frame (or something else..?) after * use 'updatePageTree' as a first parameter will set the page tree to be updated. @@ -3303,26 +3023,6 @@ class BackendUtility die('Wrong module name: "' . $modName . '"'); } - /** - * Returns the URL to a given module - * - * @param string $moduleName Name of the module - * @param array $urlParameters URL parameters that should be added as key value pairs - * @return string Calculated URL - * @deprecated since TYPO3 v9, will be removed in TYPO3 v10.0. Use UriBuilder instead. - */ - public static function getModuleUrl($moduleName, $urlParameters = []) - { - trigger_error('BackendUtility::getModuleUrl() will be removed in TYPO3 v10.0, use UriBuilder->buildUriFromRoute() instead.', E_USER_DEPRECATED); - $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class); - try { - $uri = $uriBuilder->buildUriFromRoute($moduleName, $urlParameters); - } catch (\TYPO3\CMS\Backend\Routing\Exception\RouteNotFoundException $e) { - $uri = $uriBuilder->buildUriFromRoutePath($moduleName, $urlParameters); - } - return (string)$uri; - } - /******************************************* * * Core @@ -3540,22 +3240,6 @@ class BackendUtility return $thePidValue; } - /** - * Return $uid if $table is pages and $uid is int - otherwise the $pid - * - * @param string $table Table name - * @param int $uid Record uid - * @param int $pid Record pid - * @return int - * @internal - * @deprecated since TYPO3 v9, will be removed with TYPO3 v10.0 - */ - public static function getPidForModTSconfig($table, $uid, $pid) - { - trigger_error('BackendUtility::getPidForModTSconfig() will be removed in TYPO3 v10.0.', E_USER_DEPRECATED); - return $table === 'pages' && MathUtility::canBeInterpretedAsInteger($uid) ? $uid : $pid; - } - /** * Return the real pid of a record and caches the result. * The non-cached method needs database queries to do the job, so this method @@ -3620,56 +3304,6 @@ class BackendUtility return null; } - /** - * Returns the sys_domain record for $domain, optionally with $path appended. - * - * @param string $domain Domain name - * @param string $path Appended path - * @return array|bool Domain record, if found, false otherwise - * @deprecated since TYPO3 v9.4, will be removed in TYPO3 v10.0. Use Link Generation / Router instead. - */ - public static function getDomainStartPage($domain, $path = '') - { - trigger_error('BackendUtility::getDomainStartPage() will be removed in TYPO3 v10.0. Use the new Link Generation functionality instead.', E_USER_DEPRECATED); - $domain = explode(':', $domain); - $domain = strtolower(preg_replace('/\\.$/', '', $domain[0])); - // Path is calculated. - $path = trim(preg_replace('/\\/[^\\/]*$/', '', $path)); - // Stuff - $domain .= $path; - - $queryBuilder = static::getQueryBuilderForTable('sys_domain'); - $queryBuilder->getRestrictions() - ->removeAll() - ->add(GeneralUtility::makeInstance(DeletedRestriction::class)); - - $result = $queryBuilder - ->select('sys_domain.*') - ->from('sys_domain') - ->from('pages') - ->where( - $queryBuilder->expr()->eq( - 'sys_domain.pid', - $queryBuilder->quoteIdentifier('pages.uid') - ), - $queryBuilder->expr()->orX( - $queryBuilder->expr()->eq( - 'sys_domain.domainName', - $queryBuilder->createNamedParameter($domain, \PDO::PARAM_STR) - ), - $queryBuilder->expr()->eq( - 'sys_domain.domainName', - $queryBuilder->createNamedParameter($domain . '/', \PDO::PARAM_STR) - ) - ) - - ) - ->execute() - ->fetch(); - - return $result; - } - /** * Returns soft-reference parser for the softRef processing type * Usage: $softRefObj = &BackendUtility::softRefParserObj('[parser key]'); @@ -4511,25 +4145,6 @@ class BackendUtility return !empty($GLOBALS['TCA'][$table]['ctrl']['security']['ignoreRootLevelRestriction']); } - /** - * Exists already a shortcut entry for this TYPO3 url? - * - * @param string $url - * @deprecated since TYPO3 v9, will be removed with TYPO3 v10.0. - * - * @return bool - */ - public static function shortcutExists($url) - { - trigger_error( - 'Method BackendUtility::shortcutExists() has been marked as deprecated and will be removed in TYPO3 v10.0. Use an instance of ShortcutRepository instead.', - E_USER_DEPRECATED - ); - - $shortcutRepository = GeneralUtility::makeInstance(ShortcutRepository::class); - return $shortcutRepository->shortcutExists($url); - } - /** * Get the SignalSlot dispatcher * 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 3f9c725d1dd2..000000000000 --- a/typo3/sysext/backend/Tests/UnitDeprecated/Utility/BackendUtilityTest.php +++ /dev/null @@ -1,309 +0,0 @@ -<?php -namespace TYPO3\CMS\Backend\Tests\UnitDeprecated\Utility; - -/* - * 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! - */ - -use TYPO3\CMS\Backend\Tests\UnitDeprecated\Utility\Fixtures\BackendUtilityFixture; -use TYPO3\CMS\Backend\Utility\BackendUtility; -use TYPO3\CMS\Core\Authentication\BackendUserAuthentication; -use TYPO3\TestingFramework\Core\Unit\UnitTestCase; - -/** - * Test case - */ -class BackendUtilityTest extends UnitTestCase -{ - /** - * @test - */ - public function getModTSconfigIgnoresValuesFromUserTsConfigIfNotSet() - { - $completeConfiguration = [ - 'value' => 'bar', - 'properties' => [ - 'permissions.' => [ - 'file.' => [ - 'default.' => ['readAction' => '1'], - '1.' => ['writeAction' => '1'], - '0.' => ['readAction' => '0'], - ], - ] - ] - ]; - - $GLOBALS['BE_USER'] = $this->createMock(BackendUserAuthentication::class); - $GLOBALS['BE_USER']->expects($this->at(0))->method('getTSConfig')->will($this->returnValue($completeConfiguration)); - $GLOBALS['BE_USER']->expects($this->at(1))->method('getTSConfig')->will($this->returnValue(['value' => null, 'properties' => null])); - - $this->assertSame($completeConfiguration, BackendUtilityFixture::getModTSconfig(42, 'notrelevant')); - } - - /////////////////////////////////////// - // Tests concerning getTCAtypes - /////////////////////////////////////// - - /** - * @test - */ - public function getTCAtypesReturnsCorrectValuesDataProvider() - { - return [ - 'no input' => [ - '', // table - [], // rec - '', // useFieldNameAsKey - null // expected - ], - 'non-existant table' => [ - 'fooBar', // table - [], // rec - '', // useFieldNameAsKey - null // expected - ], - 'Doktype=1: one simple field' => [ - 'pages', - [ - 'uid' => '1', - 'doktype' => '1' - ], - false, - [ - 0 => [ - 'field' => 'title', - 'title' => null, - 'palette' => null, - 'spec' => [], - 'origString' => 'title' - ] - ] - ], - 'non-existant type given: Return for type 1' => [ - 'pages', // table - [ - 'uid' => '1', - 'doktype' => '999' - ], // rec - '', // useFieldNameAsKey - [ - 0 => [ - 'field' => 'title', - 'title' => null, - 'palette' => null, - 'spec' => [], - 'origString' => 'title' - ] - ] // expected - ], - 'Doktype=1: one simple field, useFieldNameAsKey=true' => [ - 'pages', - [ - 'uid' => '1', - 'doktype' => '1' - ], - true, - [ - 'title' => [ - 'field' => 'title', - 'title' => null, - 'palette' => null, - 'spec' => [], - 'origString' => 'title' - ] - ] - ], - 'Empty showitem Field' => [ - 'test', - [ - 'uid' => '1', - 'fooBar' => '99' - ], - true, - [ - '' => [ - 'field' => '', - 'title' => null, - 'palette' => null, - 'spec' => [], - 'origString' => '' - ] - ] - ], - 'RTE field within a palette' => [ - 'pages', - [ - 'uid' => '1', - 'doktype' => '10', - ], - false, - [ - 0 => [ - 'field' => '--div--', - 'title' => 'General', - 'palette' => null, - 'spec' => [], - 'origString' => '--div--;General' - ], - 1 => [ - 'field' => '--palette--', - 'title' => 'Palette', - 'palette' => '123', - 'spec' => [], - 'origString' => '--palette--;Palette;123' - ], - 2 => [ - 'field' => 'title', - 'title' => null, - 'palette' => null, - 'spec' => [], - 'origString' => 'title' - ], - 3 => [ - 'field' => 'text', - 'title' => null, - 'palette' => null, - 'spec' => [], - 'origString' => 'text' - ], - 4 => [ - 'field' => 'select', - 'title' => 'Select field', - 'palette' => null, - 'spec' => [], - 'origString' => 'select;Select field' - ] - ] - ], - 'RTE field with more settings within a palette' => [ - 'pages', - [ - 'uid' => 1, - 'doktype' => 2 - ], - false, - [ - 0 => [ - 'field' => '--div--', - 'title' => 'General', - 'palette' => null, - 'spec' => [], - 'origString' => '--div--;General' - ], - 1 => [ - 'field' => '--palette--', - 'title' => 'RTE palette', - 'palette' => '456', - 'spec' => [], - 'origString' => '--palette--;RTE palette;456' - ], - 2 => [ - 'field' => 'text2', - 'title' => null, - 'palette' => null, - 'spec' => [], - 'origString' => 'text2' - ] - ] - ] - ]; - } - - /** - * @test - * @dataProvider getTCAtypesReturnsCorrectValuesDataProvider - * - * @param string $table - * @param array $rec - * @param bool $useFieldNameAsKey - * @param array $expected - */ - public function getTCAtypesReturnsCorrectValues($table, $rec, $useFieldNameAsKey, $expected) - { - $GLOBALS['TCA'] = [ - 'pages' => [ - 'ctrl' => [ - 'type' => 'doktype' - ], - 'columns' => [ - 'title' => [ - 'label' => 'Title test', - 'config' => [ - 'type' => 'input' - ] - ], - 'text' => [ - 'label' => 'RTE Text', - 'config' => [ - 'type' => 'text', - 'cols' => 40, - 'rows' => 5 - ], - ], - 'text2' => [ - 'label' => 'RTE Text 2', - 'config' => [ - 'type' => 'text', - 'cols' => 40, - 'rows' => 5 - ], - ], - 'select' => [ - 'label' => 'Select test', - 'config' => [ - 'items' => [ - ['Please select', 0], - ['Option 1', 1], - ['Option 2', 2] - ] - ], - 'maxitems' => 1, - 'renderType' => 'selectSingle' - ] - ], - 'types' => [ - '1' => [ - 'showitem' => 'title' - ], - '2' => [ - 'showitem' => '--div--;General,--palette--;RTE palette;456' - ], - '10' => [ - 'showitem' => '--div--;General,--palette--;Palette;123,title' - ], - '14' => [ - 'showitem' => '--div--;General,title' - ] - ], - 'palettes' => [ - '123' => [ - 'showitem' => 'text,select;Select field' - ], - '456' => [ - 'showitem' => 'text2' - ] - ] - ], - 'test' => [ - 'ctrl' => [ - 'type' => 'fooBar' - ], - 'types' => [ - '99' => [ 'showitem' => ''] - ] - ] - ]; - - $return = BackendUtility::getTCAtypes($table, $rec, $useFieldNameAsKey); - $this->assertSame($expected, $return); - } -} diff --git a/typo3/sysext/backend/Tests/UnitDeprecated/Utility/Fixtures/BackendUtilityFixture.php b/typo3/sysext/backend/Tests/UnitDeprecated/Utility/Fixtures/BackendUtilityFixture.php deleted file mode 100644 index 3c3cddf7196c..000000000000 --- a/typo3/sysext/backend/Tests/UnitDeprecated/Utility/Fixtures/BackendUtilityFixture.php +++ /dev/null @@ -1,34 +0,0 @@ -<?php -namespace TYPO3\CMS\Backend\Tests\UnitDeprecated\Utility\Fixtures; - -/* - * 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! - */ - -use TYPO3\CMS\Backend\Utility\BackendUtility; - -/** - * BackendUtility fixture - */ -class BackendUtilityFixture extends BackendUtility -{ - /** - * @param int $id - * @param array $rootLine - * @param bool $returnPartArray - * @return array - */ - public static function getPagesTSconfig($id, $rootLine = null, $returnPartArray = false) - { - return []; - } -} diff --git a/typo3/sysext/core/Documentation/Changelog/master/Breaking-87193-DeprecatedFunctionalityRemoved.rst b/typo3/sysext/core/Documentation/Changelog/master/Breaking-87193-DeprecatedFunctionalityRemoved.rst index 1517c7f7b288..bf6d775d10d6 100644 --- a/typo3/sysext/core/Documentation/Changelog/master/Breaking-87193-DeprecatedFunctionalityRemoved.rst +++ b/typo3/sysext/core/Documentation/Changelog/master/Breaking-87193-DeprecatedFunctionalityRemoved.rst @@ -29,9 +29,28 @@ The following PHP class methods that have been previously deprecated for v9 have * :php:`TYPO3\CMS\Core\Charset\CharsetConverter->utf8_char2byte_pos()` * :php:`TYPO3\CMS\Core\Charset\CharsetConverter->utf8_to_entities()` + +The following PHP static class methods that have been previously deprecated for v9 have been removed: + +* :php:`TYPO3\CMS\Backend\Utility\BackendUtility::deleteClause()` +* :php:`TYPO3\CMS\Backend\Utility\BackendUtility::getOriginalTranslationTable()` +* :php:`TYPO3\CMS\Backend\Utility\BackendUtility::getTCAtypes()` +* :php:`TYPO3\CMS\Backend\Utility\BackendUtility::storeHash()` +* :php:`TYPO3\CMS\Backend\Utility\BackendUtility::getHash()` +* :php:`TYPO3\CMS\Backend\Utility\BackendUtility::getListGroupNames()` +* :php:`TYPO3\CMS\Backend\Utility\BackendUtility::getModTSconfig()` +* :php:`TYPO3\CMS\Backend\Utility\BackendUtility::unsetMenuItems()` +* :php:`TYPO3\CMS\Backend\Utility\BackendUtility::getModuleUrl()` +* :php:`TYPO3\CMS\Backend\Utility\BackendUtility::getPidForModTSconfig()` +* :php:`TYPO3\CMS\Backend\Utility\BackendUtility::getDomainStartPage()` +* :php:`TYPO3\CMS\Backend\Utility\BackendUtility::shortcutExists()` + + The following methods changed signature according to previous deprecations in v9 at the end of the argument list: * :php:`TYPO3\CMS\Core\Charset\CharsetConverter->conv()` - Fourth argument dropped +* :php:`TYPO3\CMS\Backend\Utility\BackendUtility::getPagesTSconfig()` - Second and third argument dropped + The following public class properties have been dropped: @@ -50,6 +69,11 @@ The following scheduler tasks have been removed: * EXT:workspaces CleanupPreviewLinkTask * EXT:workspaces AutoPublishTask +The following user TSconfig options have been dropped: + +* Prefix `mod.` to override page TSconfig is ignored + + Impact ====== diff --git a/typo3/sysext/core/Tests/Unit/Service/FlexFormServiceTest.php b/typo3/sysext/core/Tests/Unit/Service/FlexFormServiceTest.php index 3d83defada76..75517ab12b74 100644 --- a/typo3/sysext/core/Tests/Unit/Service/FlexFormServiceTest.php +++ b/typo3/sysext/core/Tests/Unit/Service/FlexFormServiceTest.php @@ -101,8 +101,7 @@ class FlexFormServiceTest extends UnitTestCase ] ]; - // The subject calls xml2array statically, which calls getHash and setHash statically, which uses - // caches, those need to be mocked. + // The subject calls xml2array statically, which calls a runtime cache, this need to be mocked. $cacheManagerMock = $this->createMock(\TYPO3\CMS\Core\Cache\CacheManager::class); $cacheMock = $this->createMock(\TYPO3\CMS\Core\Cache\Frontend\FrontendInterface::class); $cacheManagerMock->expects($this->any())->method('getCache')->will($this->returnValue($cacheMock)); diff --git a/typo3/sysext/extbase/Tests/Unit/Mvc/Web/Routing/UriBuilderTest.php b/typo3/sysext/extbase/Tests/Unit/Mvc/Web/Routing/UriBuilderTest.php index d52c2eea73b5..f670655ad0db 100644 --- a/typo3/sysext/extbase/Tests/Unit/Mvc/Web/Routing/UriBuilderTest.php +++ b/typo3/sysext/extbase/Tests/Unit/Mvc/Web/Routing/UriBuilderTest.php @@ -16,7 +16,6 @@ namespace TYPO3\CMS\Extbase\Tests\Unit\Mvc\Web\Routing; */ use TYPO3\CMS\Backend\Routing\Route; use TYPO3\CMS\Backend\Routing\Router; -use TYPO3\CMS\Core\Authentication\BackendUserAuthentication; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Extbase\Configuration\ConfigurationManager; use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface; @@ -89,10 +88,6 @@ class UriBuilderTest extends UnitTestCase $router->addRoute('module_key', new Route('/test/Path', [])); $router->addRoute('module_key2', new Route('/test/Path2', [])); $router->addRoute('', new Route('', [])); - // Mocking backend user is required for backend URI generation as BackendUtility::getModuleUrl() is called - $backendUserMock = $this->createMock(BackendUserAuthentication::class); - $backendUserMock->expects($this->any())->method('check')->will($this->returnValue(true)); - $GLOBALS['BE_USER'] = $backendUserMock; } /** diff --git a/typo3/sysext/install/Configuration/ExtensionScanner/Php/MethodArgumentDroppedStaticMatcher.php b/typo3/sysext/install/Configuration/ExtensionScanner/Php/MethodArgumentDroppedStaticMatcher.php index dfd8f714d1bb..dae990e25957 100644 --- a/typo3/sysext/install/Configuration/ExtensionScanner/Php/MethodArgumentDroppedStaticMatcher.php +++ b/typo3/sysext/install/Configuration/ExtensionScanner/Php/MethodArgumentDroppedStaticMatcher.php @@ -31,6 +31,7 @@ return [ 'maximumNumberOfArguments' => 1, 'restFiles' => [ 'Deprecation-54152-DeprecateArgumentsOfBackendUtilityGetPagesTSconfig.rst', + 'Breaking-87193-DeprecatedFunctionalityRemoved.rst', ], ], 'TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded' => [ diff --git a/typo3/sysext/install/Configuration/ExtensionScanner/Php/MethodCallStaticMatcher.php b/typo3/sysext/install/Configuration/ExtensionScanner/Php/MethodCallStaticMatcher.php index 574f3c24dca9..6317f324c649 100644 --- a/typo3/sysext/install/Configuration/ExtensionScanner/Php/MethodCallStaticMatcher.php +++ b/typo3/sysext/install/Configuration/ExtensionScanner/Php/MethodCallStaticMatcher.php @@ -419,6 +419,7 @@ return [ 'maximumNumberOfArguments' => 1, 'restFiles' => [ 'Deprecation-81534-BackendUtilitygetListGroupNamesDeprecated.rst', + 'Breaking-87193-DeprecatedFunctionalityRemoved.rst', ], ], 'TYPO3\CMS\Core\Utility\GeneralUtility::makeRedirectUrl' => [ @@ -496,6 +497,7 @@ return [ 'maximumNumberOfArguments' => 1, 'restFiles' => [ 'Deprecation-82445-PageTranslationRelatedFunctionality.rst', + 'Breaking-87193-DeprecatedFunctionalityRemoved.rst', ], ], 'TYPO3\CMS\Core\Utility\GeneralUtility::llXmlAutoFileName' => [ @@ -510,6 +512,7 @@ return [ 'maximumNumberOfArguments' => 1, 'restFiles' => [ 'Deprecation-83116-CachingFrameworkWrapperMethodsInBackendUtility.rst', + 'Breaking-87193-DeprecatedFunctionalityRemoved.rst', ], ], 'TYPO3\CMS\Backend\Utility\BackendUtility::storeHash' => [ @@ -517,6 +520,7 @@ return [ 'maximumNumberOfArguments' => 3, 'restFiles' => [ 'Deprecation-83116-CachingFrameworkWrapperMethodsInBackendUtility.rst', + 'Breaking-87193-DeprecatedFunctionalityRemoved.rst', ], ], 'TYPO3\CMS\Backend\Utility\BackendUtility::deleteClause' => [ @@ -524,6 +528,7 @@ return [ 'maximumNumberOfArguments' => 2, 'restFiles' => [ 'Deprecation-83118-DeleteClauseMethods.rst', + 'Breaking-87193-DeprecatedFunctionalityRemoved.rst', ], ], 'TYPO3\CMS\Frontend\Page\PageGenerator::generatePageTitle' => [ @@ -552,6 +557,7 @@ return [ 'maximumNumberOfArguments' => 3, 'restFiles' => [ 'Deprecation-84994-BackendUtilitygetPidForModTSconfigDeprecated.rst', + 'Breaking-87193-DeprecatedFunctionalityRemoved.rst', ], ], 'TYPO3\CMS\Backend\Utility\BackendUtility::getModTSconfig' => [ @@ -559,6 +565,7 @@ return [ 'maximumNumberOfArguments' => 2, 'restFiles' => [ 'Deprecation-84993-DeprecateSomeTSconfigRelatedMethods.rst', + 'Breaking-87193-DeprecatedFunctionalityRemoved.rst', ], ], 'TYPO3\CMS\Backend\Utility\BackendUtility::unsetMenuItems' => [ @@ -566,6 +573,7 @@ return [ 'maximumNumberOfArguments' => 3, 'restFiles' => [ 'Deprecation-84993-DeprecateSomeTSconfigRelatedMethods.rst', + 'Breaking-87193-DeprecatedFunctionalityRemoved.rst', ], ], 'TYPO3\CMS\Saltedpasswords\Utility\SaltedPasswordsUtility::isUsageEnabled' => [ @@ -603,6 +611,7 @@ return [ 'maximumNumberOfArguments' => 2, 'restFiles' => [ 'Deprecation-85113-LegacyBackendModuleRoutingMethods.rst', + 'Breaking-87193-DeprecatedFunctionalityRemoved.rst', ], ], 'TYPO3\CMS\Backend\Utility\BackendUtility::shortcutExists' => [ @@ -610,6 +619,7 @@ return [ 'maximumNumberOfArguments' => 1, 'restFiles' => [ 'Deprecation-84414-BackendUtilityshortcutExists.rst', + 'Breaking-87193-DeprecatedFunctionalityRemoved.rst', ], ], 'TYPO3\CMS\Core\Utility\GeneralUtility::getHostname' => [ @@ -743,6 +753,7 @@ return [ 'maximumNumberOfArguments' => 3, 'restFiles' => [ 'Deprecation-85836-BackendUtilitygetTCAtypes.rst', + 'Breaking-87193-DeprecatedFunctionalityRemoved.rst', ], ], 'TYPO3\CMS\Core\Utility\GeneralUtility::clientInfo' => [ @@ -778,6 +789,7 @@ return [ 'maximumNumberOfArguments' => 2, 'restFiles' => [ 'Deprecation-85892-VariousMethodsRegardingSysDomainResolving.rst', + 'Breaking-87193-DeprecatedFunctionalityRemoved.rst', ], ], 'TYPO3\CMS\Backend\Utility\BackendUtility::firstDomainRecord' => [ -- GitLab