diff --git a/typo3/sysext/backend/Classes/Preview/StandardContentPreviewRenderer.php b/typo3/sysext/backend/Classes/Preview/StandardContentPreviewRenderer.php index 85385f073162e6e8a41634d4f61d72c04252d89f..93fee90c4cb6394060a4a45a18114d06d657214b 100644 --- a/typo3/sysext/backend/Classes/Preview/StandardContentPreviewRenderer.php +++ b/typo3/sysext/backend/Classes/Preview/StandardContentPreviewRenderer.php @@ -155,9 +155,7 @@ class StandardContentPreviewRenderer implements PreviewRendererInterface, Logger $icon, $tableName, $shortcutRecord['uid'], - 1, - '', - '+copy,info,edit,view' + 1 ); $shortcutContent[] = $icon . htmlspecialchars(BackendUtility::getRecordTitle($tableName, $shortcutRecord)); diff --git a/typo3/sysext/backend/Classes/Tree/View/FolderTreeView.php b/typo3/sysext/backend/Classes/Tree/View/FolderTreeView.php index 23d152873255ff0e9db7bff265fd28a5ea0a2b6a..5e18b65acb7345f22526521ffee3da27fde39e7e 100644 --- a/typo3/sysext/backend/Classes/Tree/View/FolderTreeView.php +++ b/typo3/sysext/backend/Classes/Tree/View/FolderTreeView.php @@ -203,7 +203,7 @@ class FolderTreeView extends AbstractTreeView } $aOnClick = 'return jumpTo(' . GeneralUtility::quoteJSvalue($this->getJumpToParam($folderObject)) . ', this, ' . GeneralUtility::quoteJSvalue($this->domIdPrefix . $this->getId($folderObject)) . ', ' . $bank . ');'; $tableName = $this->getTableNameForClickMenu($folderObject); - $clickMenuParts = BackendUtility::wrapClickMenuOnIcon('', $tableName, $folderObject->getCombinedIdentifier(), 'tree', '', '', true); + $clickMenuParts = BackendUtility::getClickMenuOnIconTagParameters($tableName, $folderObject->getCombinedIdentifier(), 'tree'); return '<a href="#" title="' . htmlspecialchars(strip_tags($title)) . '" onclick="' . htmlspecialchars($aOnClick) . '" ' . GeneralUtility::implodeAttributes($clickMenuParts) . '>' . $title . '</a>'; } diff --git a/typo3/sysext/backend/Classes/Utility/BackendUtility.php b/typo3/sysext/backend/Classes/Utility/BackendUtility.php index 746127d7117fe82e3ff0102c542a03967e4184a7..0120c13cddc069e0f9655a933212c48596a29d34 100644 --- a/typo3/sysext/backend/Classes/Utility/BackendUtility.php +++ b/typo3/sysext/backend/Classes/Utility/BackendUtility.php @@ -2407,12 +2407,12 @@ class BackendUtility * @param int|string $uid If icon is for database record this is the UID for the * record from $table or identifier for sys_file record * @param string $context Set tree if menu is called from tree view - * @param string $_addParams NOT IN USE - * @param string $_enDisItems NOT IN USE + * @param string $_addParams NOT IN USE Deprecated since TYPO3 11, will be removed in TYPO3 12. + * @param string $_enDisItems NOT IN USE Deprecated since TYPO3 11, will be removed in TYPO3 12. * @param bool $returnTagParameters If set, will return only the onclick - * JavaScript, not the whole link. + * JavaScript, not the whole link. Deprecated since TYPO3 11, will be removed in TYPO3 12. * - * @return string The link wrapped input string. + * @return string|array The link wrapped input string. */ public static function wrapClickMenuOnIcon( $content, @@ -2423,19 +2423,40 @@ class BackendUtility $_enDisItems = '', $returnTagParameters = false ) { - $tagParameters = [ - 'class' => 't3js-contextmenutrigger', - 'data-table' => $table, - 'data-uid' => $uid, - 'data-context' => $context - ]; + $tagParameters = self::getClickMenuOnIconTagParameters((string)$table, $uid, (string)$context); + if ($_addParams !== '') { + trigger_error('Calling BackendUtility::wrapClickMenuOnIcon() with unused 5th parameter is deprecated and will be removed in v12.', E_USER_DEPRECATED); + } + if ($_enDisItems !== '') { + trigger_error('Calling BackendUtility::wrapClickMenuOnIcon() with unused 6th parameter is deprecated and will be removed in v12.', E_USER_DEPRECATED); + } if ($returnTagParameters) { + trigger_error('Calling BackendUtility::wrapClickMenuOnIcon() with 7th parameter set to true is deprecated and will be removed in v12. Please use BackendUtility::getClickMenuOnIconTagParameters() instead.', E_USER_DEPRECATED); return $tagParameters; } return '<a href="#" ' . GeneralUtility::implodeAttributes($tagParameters, true) . '>' . $content . '</a>'; } + /** + * @param string $table Table name/File path. If the icon is for a database + * record, enter the tablename from $GLOBALS['TCA']. If a file then enter + * the absolute filepath + * @param int|string $uid If icon is for database record this is the UID for the + * record from $table or identifier for sys_file record + * @param string $context Set tree if menu is called from tree view + * @return array + */ + public static function getClickMenuOnIconTagParameters(string $table, $uid = 0, string $context = ''): array + { + return [ + 'class' => 't3js-contextmenutrigger', + 'data-table' => $table, + 'data-uid' => (string)$uid, + 'data-context' => $context + ]; + } + /** * Returns a URL with a command to TYPO3 Datahandler * diff --git a/typo3/sysext/core/Documentation/Changelog/master/Deprecation-92583-DeprecateLastArgumentsOfWrapClickMenuOnIcon.rst b/typo3/sysext/core/Documentation/Changelog/master/Deprecation-92583-DeprecateLastArgumentsOfWrapClickMenuOnIcon.rst new file mode 100644 index 0000000000000000000000000000000000000000..474d59a19580f7aa2ceaf72c5a2eb6e5f2bdc627 --- /dev/null +++ b/typo3/sysext/core/Documentation/Changelog/master/Deprecation-92583-DeprecateLastArgumentsOfWrapClickMenuOnIcon.rst @@ -0,0 +1,55 @@ +.. include:: ../../Includes.txt + +======================================================================= +Deprecation: #92583 - Deprecate last arguments of wrapClickMenuOnIcon() +======================================================================= + +See :issue:`92583` + +Description +=========== + +:php:`BackendUtility::wrapClickMenuOnIcon()` has a boolean flag to let the method +return an array with tag parameters instead of a fully build HTML tag as string. +As this are two completely different things and cause problems when analysing +return types it should not be done in the same method. + +Calling :php:`BackendUtility::wrapClickMenuOnIcon()` with the 7th and last argument +:php:`$returnTagParameters` set to :php:`true` has been deprecated alongside the 5th +and 6th arguments that are already unused. + +A new method has been introduced that returns the aforementioned array. + + +Impact +====== + +Calling :php:`BackendUtility::wrapClickMenuOnIcon()` with more than 4 arguments +will trigger a deprecation warning. + + +Affected Installations +====================== + +All 3rd party extensions calling :php:`BackendUtility::wrapClickMenuOnIcon()` with more +than 4 arguments are affected. + + +Migration +========= + +Arguments 4 and 5 can be safely removed as they are already unused. + +If :php:`$returnTagParameters` was set to :php:`true` the newly introduced method +:php:`BackendUtility::getClickMenuOnIconTagParameters()` should be called to +retrieve the array with the tag parameters. + +Example +======= + +.. code-block:: ts + + BackendUtility::getClickMenuOnIconTagParameters($tableName, $uid, 'tree'); + + +.. index:: Backend, FullyScanned, ext:backend diff --git a/typo3/sysext/install/Configuration/ExtensionScanner/Php/MethodArgumentDroppedMatcher.php b/typo3/sysext/install/Configuration/ExtensionScanner/Php/MethodArgumentDroppedMatcher.php index d72db1a299bf43d3eb19156716c3c1bfa80560bf..1e3e021afc3304ae2f11c044fc88d91b0523974d 100644 --- a/typo3/sysext/install/Configuration/ExtensionScanner/Php/MethodArgumentDroppedMatcher.php +++ b/typo3/sysext/install/Configuration/ExtensionScanner/Php/MethodArgumentDroppedMatcher.php @@ -243,4 +243,10 @@ return [ 'Breaking-88758-SelectiveConcatenationOfCSSFilesInResourceCompressorRemoved.rst', ], ], + 'TYPO3\CMS\Backend\Utility\BackendUtility->wrapClickMenuOnIcon' => [ + 'maximumNumberOfArguments' => 4, + 'restFiles' => [ + 'Deprecation-92583-DeprecateLastArgumentsOfWrapClickMenuOnIcon.rst', + ], + ], ];