[TASK] Various cleanups regarding comments and API calls 19/56919/3
authorBenni Mack <benni@typo3.org>
Fri, 11 May 2018 05:33:11 +0000 (07:33 +0200)
committerFrank Naegler <frank.naegler@typo3.org>
Fri, 11 May 2018 08:08:31 +0000 (10:08 +0200)
This patch is a small summary of clean ups in various
places of TYPO3 Core.

- EditDocumentController can be simplified to retrieve the closeUrl()
- Comment adaptions in GeneralUtility
- Comment adaptions and code simplification in ContentObjectRenderer
- HMENU debug option can be fetched from TSFE TypoScript directly
- TypoLinkBuilder can use "TSFE->initTemplate()" directly
  to instantiate the TemplateService, and should hand over
  proper values in the constructor.

Resolves: #84966
Releases: master
Change-Id: I145b99842eea2a2386742b1525b33a49022c9339
Reviewed-on: https://review.typo3.org/56919
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Mathias Schreiber <mathias.schreiber@typo3.com>
Tested-by: Mathias Schreiber <mathias.schreiber@typo3.com>
Reviewed-by: Frank Naegler <frank.naegler@typo3.org>
Tested-by: Frank Naegler <frank.naegler@typo3.org>
typo3/sysext/backend/Classes/Controller/EditDocumentController.php
typo3/sysext/core/Classes/Utility/GeneralUtility.php
typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php
typo3/sysext/frontend/Classes/ContentObject/Menu/AbstractMenuContentObject.php
typo3/sysext/frontend/Classes/Typolink/AbstractTypolinkBuilder.php

index e59e293..af7879e 100644 (file)
@@ -1626,7 +1626,8 @@ class EditDocumentController
         $cshButton = $buttonBar->makeHelpButton()->setModuleName('xMOD_csh_corebe')->setFieldName('TCEforms');
         $buttonBar->addButton($cshButton);
 
-        if ($this->returnUrl !== $this->getCloseUrl()) {
+        $closeUrl = $this->getCloseUrl();
+        if ($this->returnUrl !== $closeUrl) {
             $shortCutButton = $this->moduleTemplate->getDocHeaderComponent()->getButtonBar()->makeShortcutButton();
             $shortCutButton->setModuleName('xMOD_alt_doc.php')
                 ->setGetVariables([
@@ -1638,10 +1639,7 @@ class EditDocumentController
                     'returnNewPageId',
                     'noView']);
             $this->moduleTemplate->getDocHeaderComponent()->getButtonBar()->addButton($shortCutButton);
-        }
 
-        $closeUrl = $this->getCloseUrl();
-        if ($this->returnUrl !== $closeUrl) {
             $requestUri = GeneralUtility::linkThisScript([
                 'returnUrl' => $closeUrl,
             ]);
index ebe24a8..a294f9f 100644 (file)
@@ -2075,7 +2075,7 @@ class GeneralUtility
      * sets permissions on newly created directories.
      *
      * @param string $directory Target directory to create. Must a have trailing slash
-     * @param string $deepDirectory Directory to create. This second parameter
+     * @param string $deepDirectory Directory to create. This second parameter is deprecated since TYPO3 v9, and will be removed in TYPO3 v10.
      * @throws \InvalidArgumentException If $directory or $deepDirectory are not strings
      * @throws \RuntimeException If directory could not be created
      */
@@ -2333,7 +2333,7 @@ class GeneralUtility
      *
      * @param array $fileArr The file array to remove the prefix from
      * @param string $prefixToRemove The prefix path to remove (if found as first part of string!)
-     * @return array The input $fileArr processed.
+     * @return array|string The input $fileArr processed, or a string with an error message, when an error occurred.
      */
     public static function removePrefixPathFromList(array $fileArr, $prefixToRemove)
     {
index 766ffdf..0ec55de 100644 (file)
@@ -5559,7 +5559,7 @@ class ContentObjectRenderer implements LoggerAwareInterface
      *
      * @param string $mailAddress Email address
      * @param string $linktxt Link text, default will be the email address.
-     * @return string Returns a numerical array with two elements: 1) $mailToUrl, string ready to be inserted into the href attribute of the <a> tag, b) $linktxt: The string between starting and ending <a> tag.
+     * @return array A numerical array with two elements: 1) $mailToUrl, string ready to be inserted into the href attribute of the <a> tag, b) $linktxt: The string between starting and ending <a> tag.
      */
     public function getMailTo($mailAddress, $linktxt)
     {
@@ -5730,11 +5730,7 @@ class ContentObjectRenderer implements LoggerAwareInterface
         } else {
             $newQueryArray = $currentQueryArray;
         }
-        if ($forceOverruleArguments) {
-            ArrayUtility::mergeRecursiveWithOverrule($newQueryArray, $overruleQueryArguments);
-        } else {
-            ArrayUtility::mergeRecursiveWithOverrule($newQueryArray, $overruleQueryArguments, false);
-        }
+        ArrayUtility::mergeRecursiveWithOverrule($newQueryArray, $overruleQueryArguments, $forceOverruleArguments);
         return GeneralUtility::implodeArrayForUrl('', $newQueryArray, '', false, true);
     }
 
index 547079a..d9ea710 100644 (file)
@@ -258,7 +258,7 @@ abstract class AbstractMenuContentObject
         $this->conf = $conf;
         $this->menuNumber = $menuNumber;
         $this->mconf = $conf[$this->menuNumber . $objSuffix . '.'];
-        $this->debug = $tsfe->debug;
+        $this->debug = !empty($tsfe->config['config']['debug']);
         $this->WMcObj = GeneralUtility::makeInstance(ContentObjectRenderer::class);
         // In XHTML and HTML5 there is no "name" attribute anymore
         switch ($tsfe->xhtmlDoctype) {
index 11f4072..721676f 100644 (file)
@@ -16,7 +16,6 @@ namespace TYPO3\CMS\Frontend\Typolink;
  */
 
 use TYPO3\CMS\Core\Service\DependencyOrderingService;
-use TYPO3\CMS\Core\TypoScript\TemplateService;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
 use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;
@@ -196,14 +195,13 @@ abstract class AbstractTypolinkBuilder
             // However, this is added to avoid any exceptions when trying to create a link
             $GLOBALS['TSFE'] = GeneralUtility::makeInstance(
                 TypoScriptFrontendController::class,
-                    [],
-                    (int)GeneralUtility::_GP('id'),
+                    null,
+                    GeneralUtility::_GP('id'),
                     (int)GeneralUtility::_GP('type')
             );
             $GLOBALS['TSFE']->sys_page = GeneralUtility::makeInstance(PageRepository::class);
             $GLOBALS['TSFE']->sys_page->init(false);
-            $GLOBALS['TSFE']->tmpl = GeneralUtility::makeInstance(TemplateService::class);
-            $GLOBALS['TSFE']->tmpl->init();
+            $GLOBALS['TSFE']->initTemplate();
         }
         return $GLOBALS['TSFE'];
     }