Skip to content

Commit eea7bb8

Browse files
committed
[TASK] Avoid rowCount() for select query
Using the `rowCount(` method for an `SELECT` query is not reliable. That's already documented in the TYPO3 documentation. It's recommended to use a `COUNT()` query instead. See: https://docs.typo3.org/m/typo3/reference-coreapi/10.4/en-us/ApiOverview/Database/Statement/Index.html#rowcount This change uses now a `COUNT(*)` based query to avoid the unreliable `rowCount()` method in the corresponding `WebVision\WvDeepltranslate\Upgrades\GlossaryUpgradeWizard`. This will be fixed in main within other stuffs and this is only the manual backport for the 3.x branch. Releases: 3.x
1 parent 1a76a44 commit eea7bb8

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

Classes/Upgrades/GlossaryUpgradeWizard.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -226,11 +226,13 @@ public function updateNecessary(): bool
226226
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
227227
->getQueryBuilderForTable('tx_wvdeepltranslate_domain_model_glossaries');
228228
$queryBuilder->getRestrictions()->removeAll();
229-
$statement = $queryBuilder
230-
->select('*')
231-
->from('tx_wvdeepltranslate_domain_model_glossaries');
229+
$count = (int)$queryBuilder
230+
->count('*')
231+
->from('tx_wvdeepltranslate_domain_model_glossaries')
232+
->execute()
233+
->fetchColumn(0);
232234

233-
return $statement->execute()->rowCount() > 0;
235+
return $count > 0;
234236
}
235237

236238
/**

0 commit comments

Comments
 (0)