From fd043c7d94e6f885353aed07969dac8078040f10 Mon Sep 17 00:00:00 2001 From: "c.essl" <indy.essl@gmail.com> Date: Fri, 24 May 2019 22:20:34 +0200 Subject: [PATCH] [BUGFIX] Add $TSkey labels for internal debugging MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch adds $TSkey labels to a few calls to cObjGetSingle() to improve the debugging experience with the TS tree in the AdminPanel and to avoid nondescriptive "__" strings as labels. It also improves the profiler output for cObjectViewHelper Resolves: #64906 Releases: master, 9.5 Change-Id: Iaf500390f0c6e329e15b2ff6677e8c3ebb54df5f Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/60820 Tested-by: TYPO3com <noreply@typo3.com> Tested-by: Christian Eßl <indy.essl@gmail.com> Tested-by: Susanne Moog <look@susi.dev> Reviewed-by: Christian Eßl <indy.essl@gmail.com> Reviewed-by: Susanne Moog <look@susi.dev> --- .../Classes/ViewHelpers/CObjectViewHelper.php | 27 ++++++++++++++++++- .../ViewHelpers/CObjectViewHelperTest.php | 2 +- .../Domain/Finishers/ConfirmationFinisher.php | 2 +- .../Mvc/Configuration/TypoScriptService.php | 3 ++- .../ContentObject/FilesContentObject.php | 2 +- .../FluidTemplateContentObject.php | 4 +-- 6 files changed, 33 insertions(+), 7 deletions(-) diff --git a/typo3/sysext/fluid/Classes/ViewHelpers/CObjectViewHelper.php b/typo3/sysext/fluid/Classes/ViewHelpers/CObjectViewHelper.php index eae14dc02e5a..4c2f28703f6b 100644 --- a/typo3/sysext/fluid/Classes/ViewHelpers/CObjectViewHelper.php +++ b/typo3/sysext/fluid/Classes/ViewHelpers/CObjectViewHelper.php @@ -15,6 +15,7 @@ namespace TYPO3\CMS\Fluid\ViewHelpers; */ use TYPO3\CMS\Core\Context\Context; +use TYPO3\CMS\Core\TimeTracker\TimeTracker; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface; use TYPO3\CMS\Extbase\Object\ObjectManager; @@ -163,13 +164,37 @@ class CObjectViewHelper extends AbstractViewHelper 1540246570 ); } - $content = $contentObjectRenderer->cObjGetSingle($setup[$lastSegment], $setup[$lastSegment . '.'] ?? []); + $content = self::renderContentObject($contentObjectRenderer, $setup, $typoscriptObjectPath, $lastSegment); if (!isset($GLOBALS['TSFE']) || !($GLOBALS['TSFE'] instanceof TypoScriptFrontendController)) { static::resetFrontendEnvironment(); } return $content; } + /** + * Renders single content object and increases time tracker stack pointer + * + * @param ContentObjectRenderer $contentObjectRenderer + * @param array $setup + * @param string $typoscriptObjectPath + * @param string $lastSegment + * @return string + */ + protected static function renderContentObject(ContentObjectRenderer $contentObjectRenderer, array $setup, string $typoscriptObjectPath, string $lastSegment): string + { + $timeTracker = GeneralUtility::makeInstance(TimeTracker::class); + if ($timeTracker->LR) { + $timeTracker->push('/f:cObject/', '<' . $typoscriptObjectPath); + } + $timeTracker->incStackPointer(); + $content = $contentObjectRenderer->cObjGetSingle($setup[$lastSegment], $setup[$lastSegment . '.'] ?? [], $typoscriptObjectPath); + $timeTracker->decStackPointer(); + if ($timeTracker->LR) { + $timeTracker->pull($content); + } + return $content; + } + /** * @return ConfigurationManagerInterface */ diff --git a/typo3/sysext/fluid/Tests/Unit/ViewHelpers/CObjectViewHelperTest.php b/typo3/sysext/fluid/Tests/Unit/ViewHelpers/CObjectViewHelperTest.php index 223a6866355a..621bd8f8ab21 100644 --- a/typo3/sysext/fluid/Tests/Unit/ViewHelpers/CObjectViewHelperTest.php +++ b/typo3/sysext/fluid/Tests/Unit/ViewHelpers/CObjectViewHelperTest.php @@ -217,7 +217,7 @@ class CObjectViewHelperTest extends ViewHelperBaseTestcase $this->contentObjectRenderer->start(['foo'], 'table')->willReturn(); $this->contentObjectRenderer->setCurrentVal('foo')->willReturn(); - $this->contentObjectRenderer->cObjGetSingle('TEXT', $subConfigArray)->willReturn('Hello World'); + $this->contentObjectRenderer->cObjGetSingle('TEXT', $subConfigArray, Argument::any())->willReturn('Hello World'); $objectManager = $this->prophesize(ObjectManager::class); $objectManager->get(ConfigurationManagerInterface::class)->willReturn($this->configurationManager->reveal()); diff --git a/typo3/sysext/form/Classes/Domain/Finishers/ConfirmationFinisher.php b/typo3/sysext/form/Classes/Domain/Finishers/ConfirmationFinisher.php index 72064fa6c49b..ad5d8587e9e2 100644 --- a/typo3/sysext/form/Classes/Domain/Finishers/ConfirmationFinisher.php +++ b/typo3/sysext/form/Classes/Domain/Finishers/ConfirmationFinisher.php @@ -115,7 +115,7 @@ class ConfirmationFinisher extends AbstractFinisher } $this->contentObjectRenderer->start([$contentElementUid], ''); $this->contentObjectRenderer->setCurrentVal((string)$contentElementUid); - $message = $this->contentObjectRenderer->cObjGetSingle($setup[$lastSegment], $setup[$lastSegment . '.']); + $message = $this->contentObjectRenderer->cObjGetSingle($setup[$lastSegment], $setup[$lastSegment . '.'], $lastSegment); } else { $message = $this->parseOption('message'); } diff --git a/typo3/sysext/form/Classes/Mvc/Configuration/TypoScriptService.php b/typo3/sysext/form/Classes/Mvc/Configuration/TypoScriptService.php index 542201a50fe0..a01ff85b819e 100644 --- a/typo3/sysext/form/Classes/Mvc/Configuration/TypoScriptService.php +++ b/typo3/sysext/form/Classes/Mvc/Configuration/TypoScriptService.php @@ -78,7 +78,8 @@ class TypoScriptService if (isset($configuration[$keyWithoutDot]) && isset($configuration[$keyWithoutDot . '.'])) { $value = $this->getTypoScriptFrontendController()->cObj->cObjGetSingle( $configuration[$keyWithoutDot], - $configuration[$keyWithoutDot . '.'] + $configuration[$keyWithoutDot . '.'], + $keyWithoutDot ); $configuration[$keyWithoutDot] = $value; } elseif (!isset($configuration[$keyWithoutDot]) && isset($configuration[$keyWithoutDot . '.'])) { diff --git a/typo3/sysext/frontend/Classes/ContentObject/FilesContentObject.php b/typo3/sysext/frontend/Classes/ContentObject/FilesContentObject.php index 9ce13e3ff056..18090df501ec 100644 --- a/typo3/sysext/frontend/Classes/ContentObject/FilesContentObject.php +++ b/typo3/sysext/frontend/Classes/ContentObject/FilesContentObject.php @@ -80,7 +80,7 @@ class FilesContentObject extends AbstractContentObject $GLOBALS['TSFE']->register['FILE_NUM_CURRENT'] = $fileObjectCounter; } $this->cObj->setCurrentFile($fileObject); - $content .= $this->cObj->cObjGetSingle($splitConf[$key]['renderObj'], $splitConf[$key]['renderObj.']); + $content .= $this->cObj->cObjGetSingle($splitConf[$key]['renderObj'], $splitConf[$key]['renderObj.'], 'renderObj'); $fileObjectCounter++; } diff --git a/typo3/sysext/frontend/Classes/ContentObject/FluidTemplateContentObject.php b/typo3/sysext/frontend/Classes/ContentObject/FluidTemplateContentObject.php index e96da23a1cba..e422f43f1ee8 100644 --- a/typo3/sysext/frontend/Classes/ContentObject/FluidTemplateContentObject.php +++ b/typo3/sysext/frontend/Classes/ContentObject/FluidTemplateContentObject.php @@ -162,7 +162,7 @@ class FluidTemplateContentObject extends AbstractContentObject $this->view->setTemplate($templateName); } elseif (!empty($conf['template']) && !empty($conf['template.'])) { // Fetch the Fluid template by template cObject - $templateSource = $this->cObj->cObjGetSingle($conf['template'], $conf['template.']); + $templateSource = $this->cObj->cObjGetSingle($conf['template'], $conf['template.'], 'template'); if ($templateSource === '') { throw new ContentRenderingException( 'Could not find template source for ' . $conf['template'], @@ -319,7 +319,7 @@ class FluidTemplateContentObject extends AbstractContentObject continue; } if (!in_array($variableName, $reservedVariables)) { - $variables[$variableName] = $this->cObj->cObjGetSingle($cObjType, $variablesToProcess[$variableName . '.']); + $variables[$variableName] = $this->cObj->cObjGetSingle($cObjType, $variablesToProcess[$variableName . '.'], 'variables.' . $variableName); } else { throw new \InvalidArgumentException( 'Cannot use reserved name "' . $variableName . '" as variable name in FLUIDTEMPLATE.', -- GitLab