diff --git a/typo3/sysext/backend/Classes/Utility/BackendUtility.php b/typo3/sysext/backend/Classes/Utility/BackendUtility.php index 7e417151540c2911edcc0e88f14df2ff86d5af9f..428fd7830fa27a8d417c2b2bb389902bcb1bdb4b 100644 --- a/typo3/sysext/backend/Classes/Utility/BackendUtility.php +++ b/typo3/sysext/backend/Classes/Utility/BackendUtility.php @@ -83,9 +83,11 @@ class BackendUtility * @param string $table Table name present in $GLOBALS['TCA'] * @param string $tableAlias Table alias if any * @return string WHERE clause for filtering out deleted records, eg " AND tablename.deleted=0 + * @deprecated since TYPO3 v9, will be removed in TYPO3 v10, the DeletedRestriction functionality should be used instead. */ public static function deleteClause($table, $tableAlias = '') { + trigger_error('This method will be removed in TYPO3 v10. Add the delete statement directly in your SQL statement via the DeletedRestriction', E_USER_DEPRECATED); if (empty($GLOBALS['TCA'][$table]['ctrl']['delete'])) { return ''; } diff --git a/typo3/sysext/core/Documentation/Changelog/master/Deprecation-83118-DeleteClauseMethods.rst b/typo3/sysext/core/Documentation/Changelog/master/Deprecation-83118-DeleteClauseMethods.rst new file mode 100644 index 0000000000000000000000000000000000000000..729c4026a82fa5561fa30a1faf0f752d6e923552 --- /dev/null +++ b/typo3/sysext/core/Documentation/Changelog/master/Deprecation-83118-DeleteClauseMethods.rst @@ -0,0 +1,34 @@ +.. include:: ../../Includes.txt + +===================================================== +Deprecation: #83118 - DeleteClause methods deprecated +===================================================== + +See :issue:`83118` + +Description +=========== + +The PHP methods :php:`PageRepository::deleteClause()` and :php:`BackendUtility::deleteClause()` have been +marked as deprecated, as all database queries are now put through Doctrine DBAL's restriction functionality. + + +Impact +====== + +Calling one of the two methods above will trigger a deprecation log entry. + + +Affected Installations +====================== + +Any TYPO3 extension using any of the two methods above. + + +Migration +========= + +Migrate to Doctrine DBAL and use the new Database API (ConnectionPool, QueryBuilder) to access the database +with the :php:`DeletedRestriction` class. + +.. index:: PHP-API, FullyScanned \ No newline at end of file diff --git a/typo3/sysext/extbase/Classes/Persistence/Generic/Storage/Typo3DbQueryParser.php b/typo3/sysext/extbase/Classes/Persistence/Generic/Storage/Typo3DbQueryParser.php index db00a258ed6618d53f87a4fe807b36f401cee256..6a101c6dce81265d28e7954b62512c3422fdbcf6 100644 --- a/typo3/sysext/extbase/Classes/Persistence/Generic/Storage/Typo3DbQueryParser.php +++ b/typo3/sysext/extbase/Classes/Persistence/Generic/Storage/Typo3DbQueryParser.php @@ -703,8 +703,8 @@ class Typo3DbQueryParser if (!empty($enableFieldsToBeIgnored)) { // array_combine() is necessary because of the way \TYPO3\CMS\Frontend\Page\PageRepository::enableFields() is implemented $statement .= $this->getPageRepository()->enableFields($tableName, -1, array_combine($enableFieldsToBeIgnored, $enableFieldsToBeIgnored)); - } else { - $statement .= $this->getPageRepository()->deleteClause($tableName); + } elseif (!empty($GLOBALS['TCA'][$tableName]['ctrl']['delete'])) { + $statement .= ' AND ' . $tableName . '.' . $GLOBALS['TCA'][$tableName]['ctrl']['delete'] . '=0'; } } elseif (!$ignoreEnableFields && !$includeDeleted) { $statement .= $this->getPageRepository()->enableFields($tableName); @@ -728,8 +728,8 @@ class Typo3DbQueryParser if (!$ignoreEnableFields) { $statement .= BackendUtility::BEenableFields($tableName); } - if (!$includeDeleted) { - $statement .= BackendUtility::deleteClause($tableName); + if (!$includeDeleted && !empty($GLOBALS['TCA'][$tableName]['ctrl']['delete'])) { + $statement .= ' AND ' . $tableName . '.' . $GLOBALS['TCA'][$tableName]['ctrl']['delete'] . '=0'; } return $statement; } diff --git a/typo3/sysext/extbase/Tests/Unit/Persistence/Generic/Storage/Typo3DbQueryParserTest.php b/typo3/sysext/extbase/Tests/Unit/Persistence/Generic/Storage/Typo3DbQueryParserTest.php index 430e60e9a00e5cb575a659d97be469a80aadbb29..2b8ab8757aaa99159affb20210c60dc6290fa665 100644 --- a/typo3/sysext/extbase/Tests/Unit/Persistence/Generic/Storage/Typo3DbQueryParserTest.php +++ b/typo3/sysext/extbase/Tests/Unit/Persistence/Generic/Storage/Typo3DbQueryParserTest.php @@ -617,9 +617,9 @@ class Typo3DbQueryParserTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestC { return [ 'in be: include all' => ['BE', true, [], true, ''], - 'in be: ignore enable fields but do not include deleted' => ['BE', true, [], false, 'tx_foo_table.deleted_column = 0'], + 'in be: ignore enable fields but do not include deleted' => ['BE', true, [], false, 'tx_foo_table.deleted_column=0'], 'in be: respect enable fields but include deleted' => ['BE', false, [], true, '(tx_foo_table.disabled_column = 0) AND (tx_foo_table.starttime_column <= 123456789)'], - 'in be: respect enable fields and do not include deleted' => ['BE', false, [], false, '(tx_foo_table.disabled_column = 0) AND (tx_foo_table.starttime_column <= 123456789) AND tx_foo_table.deleted_column = 0'], + 'in be: respect enable fields and do not include deleted' => ['BE', false, [], false, '(tx_foo_table.disabled_column = 0) AND (tx_foo_table.starttime_column <= 123456789) AND tx_foo_table.deleted_column=0'], 'in fe: include all' => ['FE', true, [], true, ''], 'in fe: ignore enable fields but do not include deleted' => ['FE', true, [], false, 'tx_foo_table.deleted_column=0'], 'in fe: ignore only starttime and do not include deleted' => ['FE', true, ['starttime'], false, '(tx_foo_table.deleted_column = 0) AND (tx_foo_table.disabled_column = 0)'], @@ -688,7 +688,7 @@ class Typo3DbQueryParserTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestC { return [ 'in be: respectEnableFields=false' => ['BE', false, ''], - 'in be: respectEnableFields=true' => ['BE', true, '(tx_foo_table.disabled_column = 0) AND (tx_foo_table.starttime_column <= 123456789) AND tx_foo_table.deleted_column = 0'], + 'in be: respectEnableFields=true' => ['BE', true, '(tx_foo_table.disabled_column = 0) AND (tx_foo_table.starttime_column <= 123456789) AND tx_foo_table.deleted_column=0'], 'in FE: respectEnableFields=false' => ['FE', false, ''], 'in FE: respectEnableFields=true' => ['FE', true, '(tx_foo_table.deleted_column = 0) AND (tx_foo_table.disabled_column = 0) AND (tx_foo_table.starttime_column <= 123456789)'] ]; diff --git a/typo3/sysext/frontend/Classes/Page/PageRepository.php b/typo3/sysext/frontend/Classes/Page/PageRepository.php index abaa43274305131d34a1a0c01c6a1d9f5cbc18dc..0d2a44d7c5c1184e7a829549c420ab88fd6b0619 100644 --- a/typo3/sysext/frontend/Classes/Page/PageRepository.php +++ b/typo3/sysext/frontend/Classes/Page/PageRepository.php @@ -1277,9 +1277,11 @@ class PageRepository implements LoggerAwareInterface * @param string $table Tablename * @return string * @see enableFields() + * @deprecated since TYPO3 v9, will be removed in TYPO3 v10, use QueryBuilders' Restrictions directly instead. */ public function deleteClause($table) { + trigger_error('The delete clause can be applied via the DeletedRestrictions via QueryBuilder, this method will be removed in TYPO3 v10.0', E_USER_DEPRECATED); return $GLOBALS['TCA'][$table]['ctrl']['delete'] ? ' AND ' . $table . '.' . $GLOBALS['TCA'][$table]['ctrl']['delete'] . '=0' : ''; } @@ -1298,7 +1300,7 @@ class PageRepository implements LoggerAwareInterface * @param bool $noVersionPreview If set, enableFields will be applied regardless of any versioning preview settings which might otherwise disable enableFields * @throws \InvalidArgumentException * @return string The clause starting like " AND ...=... AND ...=... - * @see \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::enableFields(), deleteClause() + * @see \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::enableFields() */ public function enableFields($table, $show_hidden = -1, $ignore_array = [], $noVersionPreview = false) { diff --git a/typo3/sysext/install/Configuration/ExtensionScanner/Php/MethodCallMatcher.php b/typo3/sysext/install/Configuration/ExtensionScanner/Php/MethodCallMatcher.php index 99ed4e29ffecde591b64c639bf89891752d20d23..cb94db705f28667eca12d0e737cdecafa22a94e2 100644 --- a/typo3/sysext/install/Configuration/ExtensionScanner/Php/MethodCallMatcher.php +++ b/typo3/sysext/install/Configuration/ExtensionScanner/Php/MethodCallMatcher.php @@ -1409,4 +1409,11 @@ return [ 'Deprecation-83121-LoggingMethodDataHandler-newlog2.rst', ], ], + 'TYPO3\CMS\Frontend\Page\PageRepository->deleteClause' => [ + 'numberOfMandatoryArguments' => 1, + 'maximumNumberOfArguments' => 1, + 'restFiles' => [ + 'Deprecation-83118-DeleteClauseMethods.rst', + ], + ], ]; diff --git a/typo3/sysext/install/Configuration/ExtensionScanner/Php/MethodCallStaticMatcher.php b/typo3/sysext/install/Configuration/ExtensionScanner/Php/MethodCallStaticMatcher.php index f6e95ebba245abf1a074c3ba0298ce3554d967b8..49b793bf0972ea10f414cf8f7efa804cd6700f50 100644 --- a/typo3/sysext/install/Configuration/ExtensionScanner/Php/MethodCallStaticMatcher.php +++ b/typo3/sysext/install/Configuration/ExtensionScanner/Php/MethodCallStaticMatcher.php @@ -526,4 +526,11 @@ return [ 'Deprecation-83116-CachingFrameworkWrapperMethodsInBackendUtility.rst', ], ], + 'TYPO3\CMS\Backend\Utility\BackendUtility::deleteClause' => [ + 'numberOfMandatoryArguments' => 1, + 'maximumNumberOfArguments' => 2, + 'restFiles' => [ + 'Deprecation-83118-DeleteClauseMethods.rst', + ], + ], ];