diff --git a/typo3/sysext/core/Documentation/Changelog/master/Deprecation-85558-ContentObjectRenderer-enableFields.rst b/typo3/sysext/core/Documentation/Changelog/master/Deprecation-85558-ContentObjectRenderer-enableFields.rst new file mode 100644 index 0000000000000000000000000000000000000000..8a75814561846b8f11bcd65a150fd03759e87e49 --- /dev/null +++ b/typo3/sysext/core/Documentation/Changelog/master/Deprecation-85558-ContentObjectRenderer-enableFields.rst @@ -0,0 +1,34 @@ +.. include:: ../../Includes.txt + +========================================================= +Deprecation: #85558 - ContentObjectRenderer->enableFields +========================================================= + +See :issue:`85558` + +Description +=========== + +The public method :php:`TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer->enableFields` has been marked as +deprecated. + + +Impact +====== + +Calling the method directly will trigger a deprecation message. + + +Affected Installations +====================== + +TYPO3 installations with custom extensions calling this method directly. + + +Migration +========= + +As :php:`enableFields()` acts as a simple wrapper around :php:`PageRepository->enableFields()`, it is recommended +to instantiate PageRepository directly. + +.. index:: Frontend, PHP-API, FullyScanned, ext:frontend \ No newline at end of file diff --git a/typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php b/typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php index c2c3d2e2b23618e15f19ce42ed4b805ee57e5a23..358916812d9c0bd3e9f25642f9bad7f4c18a718a 100644 --- a/typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php +++ b/typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php @@ -6064,9 +6064,11 @@ class ContentObjectRenderer implements LoggerAwareInterface * @param bool $show_hidden If set, then you want NOT to filter out hidden records. Otherwise hidden record are filtered based on the current preview settings. * @param array $ignore_array Array you can pass where keys can be "disabled", "starttime", "endtime", "fe_group" (keys from "enablefields" in TCA) and if set they will make sure that part of the clause is not added. Thus disables the specific part of the clause. For previewing etc. * @return string The part of the where clause on the form " AND [fieldname]=0 AND ...". Eg. " AND hidden=0 AND starttime < 123345567 + * @deprecated since TYPO3 v9.4, will be removed in TYPO3 v10.0. */ public function enableFields($table, $show_hidden = false, array $ignore_array = []) { + trigger_error('cObj->enableFields() will be removed in TYPO3 v10. should be used from the PageRepository->enableFields() functionality directly.', E_USER_DEPRECATED); return $this->getTypoScriptFrontendController()->sys_page->enableFields($table, $show_hidden ? true : -1, $ignore_array); } @@ -6825,7 +6827,7 @@ class ContentObjectRenderer implements LoggerAwareInterface $constraints[] = QueryHelper::stripLogicalOperatorPrefix($tsfe->sys_page->where_hid_del); $constraints[] = QueryHelper::stripLogicalOperatorPrefix($tsfe->sys_page->where_groupAccess); } else { - $constraints[] = QueryHelper::stripLogicalOperatorPrefix($this->enableFields($table, false, $enableFieldsIgnore)); + $constraints[] = QueryHelper::stripLogicalOperatorPrefix($tsfe->sys_page->enableFields($table, -1, $enableFieldsIgnore)); } // MAKE WHERE: diff --git a/typo3/sysext/frontend/Classes/ContentObject/Menu/AbstractMenuContentObject.php b/typo3/sysext/frontend/Classes/ContentObject/Menu/AbstractMenuContentObject.php index 9690f923c6c3059b986091e170878de55d45b41d..3ff5e80bff7cc4093277c200ac9e08c33c271085 100644 --- a/typo3/sysext/frontend/Classes/ContentObject/Menu/AbstractMenuContentObject.php +++ b/typo3/sysext/frontend/Classes/ContentObject/Menu/AbstractMenuContentObject.php @@ -798,7 +798,7 @@ abstract class AbstractMenuContentObject $loadDB = GeneralUtility::makeInstance(RelationHandler::class); $loadDB->setFetchAllFields(true); $loadDB->start($specialValue, 'pages'); - $loadDB->additionalWhere['pages'] = $this->parent_cObj->enableFields('pages', false, $skippedEnableFields); + $loadDB->additionalWhere['pages'] = $this->sys_page->enableFields('pages', -1, $skippedEnableFields); $loadDB->getFromDB(); $pageLinkBuilder = GeneralUtility::makeInstance(PageLinkBuilder::class, $this->parent_cObj); foreach ($loadDB->itemArray as $val) { diff --git a/typo3/sysext/frontend/Classes/ContentObject/RecordsContentObject.php b/typo3/sysext/frontend/Classes/ContentObject/RecordsContentObject.php index 979060c76c05d5b39d15c38ba7437c8b088bbc6a..d6d72d89e02069a25a721256265ab33580c6bbd8 100644 --- a/typo3/sysext/frontend/Classes/ContentObject/RecordsContentObject.php +++ b/typo3/sysext/frontend/Classes/ContentObject/RecordsContentObject.php @@ -18,6 +18,7 @@ use TYPO3\CMS\Core\Database\RelationHandler; use TYPO3\CMS\Core\TimeTracker\TimeTracker; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Frontend\Category\Collection\CategoryCollection; +use TYPO3\CMS\Frontend\Page\PageRepository; /** * Contains RECORDS class object. @@ -92,10 +93,10 @@ class RecordsContentObject extends AbstractContentObject // Perform overlays if necessary (records coming from category collections are already overlaid) if ($source) { // Versioning preview - $GLOBALS['TSFE']->sys_page->versionOL($val['table'], $row); + $this->getPageRepository()->versionOL($val['table'], $row); // Language overlay if (is_array($row)) { - $row = $GLOBALS['TSFE']->sys_page->getLanguageOverlay($val['table'], $row); + $row = $this->getPageRepository()->getLanguageOverlay($val['table'], $row); } } // Might be unset during the overlay process @@ -149,7 +150,7 @@ class RecordsContentObject extends AbstractContentObject $loadDB->start($source, implode(',', $tables)); foreach ($loadDB->tableArray as $table => $v) { if (isset($GLOBALS['TCA'][$table])) { - $loadDB->additionalWhere[$table] = $this->cObj->enableFields($table); + $loadDB->additionalWhere[$table] = $this->getPageRepository()->enableFields($table); } } $this->data = $loadDB->getFromDB(); @@ -226,4 +227,12 @@ class RecordsContentObject extends AbstractContentObject { return GeneralUtility::makeInstance(TimeTracker::class); } + + /** + * @return PageRepository + */ + protected function getPageRepository(): PageRepository + { + return $GLOBALS['TSFE']->sys_page ?: GeneralUtility::makeInstance(PageRepository::class); + } } diff --git a/typo3/sysext/install/Configuration/ExtensionScanner/Php/MethodCallMatcher.php b/typo3/sysext/install/Configuration/ExtensionScanner/Php/MethodCallMatcher.php index 63d32942ab50bed5ca51b11abd43c6b43efc895b..7d98d5d14f6ae323c0e32e291e3247df9e6ff423 100644 --- a/typo3/sysext/install/Configuration/ExtensionScanner/Php/MethodCallMatcher.php +++ b/typo3/sysext/install/Configuration/ExtensionScanner/Php/MethodCallMatcher.php @@ -2438,6 +2438,13 @@ return [ 'Deprecation-85555-TypoScriptFrontendController-getUniqueId.rst', ], ], + 'TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer->enableFields' => [ + 'numberOfMandatoryArguments' => 1, + 'maximumNumberOfArguments' => 3, + 'restFiles' => [ + 'Deprecation-85558-ContentObjectRenderer-enableFields.rst' + ], + ], 'TYPO3\CMS\Scheduler\Classes\Controller\SchedulerModuleController->addMessage' => [ 'numberOfMandatoryArguments' => 1, 'maximumNumberOfArguments' => 2,