Deprecation: #102793 - PageRepository->enableFields
See forge#102793
Description
One of the common PHP APIs used in TYPO3 Core for fetching records is
\TYPO3\
. The method
enable
is used to enhance a database query with additional
restrictions such as filtering out versioned records from workspaces, hidden
database entries or scheduled database entries.
This method has been marked as deprecated in favor of a new method
get
.
Impact
Calling the method will trigger a PHP deprecation warning.
Affected installations
TYPO3 installations with custom extensions using the method enable
of the Page
class.
Migration
A new method called get
has been introduced
which supersedes the old method. The new method returns an array of
Composite
objects, which can be used instead.
Before (TYPO3 v12)
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
->getQueryBuilderForTable($tableName);
$constraints = GeneralUtility::makeInstance(PageRepository::class)
->enableFields($tableName);
$queryBuilder
->select('*')
->from($tableName);
->where(QueryHelper::stripLogicalOperatorPrefix($constraints);
$queryBuilder->execute();
After (TYPO3 v13)
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
->getQueryBuilderForTable($tableName);
$constraints = GeneralUtility::makeInstance(PageRepository::class)
->getDefaultConstraints($tableName);
$queryBuilder
->select('*')
->from($tableName);
if ($constraints !== []) {
$queryBuilder->where(...$constraints);
}
$queryBuilder->execute();