Commit c6ad571f authored by Claus Due's avatar Claus Due Committed by Wouter Wolters
Browse files

[BUGFIX] Avoid building SQL deleteClause expression if unused

This patch avoids building an instance of ConnectionPool,
getting a QueryBuilder and building an expression unless
that expression is needed by the function.

Also switches a condition with else clause to an early
return guard clause (cosmetic only).

Change-Id: I804b3ff9e624aa4b8b9c760d2a5e858039b6f9b9
Resolves: #78806
Releases: master
Reviewed-on: https://review.typo3.org/50784

Tested-by: default avatarTYPO3com <no-reply@typo3.com>
Reviewed-by: Stephan Großberndt's avatarStephan Großberndt <stephan@grossberndt.de>
Reviewed-by: default avatarMorton Jonuschat <m.jonuschat@mojocode.de>
Tested-by: default avatarMorton Jonuschat <m.jonuschat@mojocode.de>
Reviewed-by: Wouter Wolters's avatarWouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters's avatarWouter Wolters <typo3@wouterwolters.nl>
parent 7ff72daa
......@@ -83,18 +83,16 @@ class BackendUtility
*/
public static function deleteClause($table, $tableAlias = '')
{
if (empty($GLOBALS['TCA'][$table]['ctrl']['delete'])) {
return '';
}
$expressionBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
->getQueryBuilderForTable($table)
->expr();
if (!empty($GLOBALS['TCA'][$table]['ctrl']['delete'])) {
return ' AND ' . $expressionBuilder->eq(
($tableAlias ?: $table) . '.' . $GLOBALS['TCA'][$table]['ctrl']['delete'],
0
);
} else {
return '';
}
return ' AND ' . $expressionBuilder->eq(
($tableAlias ?: $table) . '.' . $GLOBALS['TCA'][$table]['ctrl']['delete'],
0
);
}
/**
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment