Bug #80464
opencount() not working correctly in Extbase when using custom statement
0%
Description
When creating a Query object and assigning a custom statement, the count() method in QueryResult might not work correctly (depending on the query).
Once the QueryResult is initilialized, count() will return the correct result since it will use result array.
If count() is called before that, the error appears in TYPO3\CMS\Extbase\Persistence\Generic\Storage::getObjectCountByQuery()
In my case, i have a query on an extension table where I left join another table of the same extension (as the extension is not public it would be no use to add the statement here).
The problem is: the joined table, a condition referencing the joined table as well as one (the last) condition referencing the main table are ignored within getObjectCountByQuery().
The result is that getObjectCountByQuery() effectively returns the raw count of all records in the main table that are not deleted or hidden (in this case).
If count() is not supposed to work with custom statements, this should be annotated in the code and I would prefer returning "NULL" or "false" as a default in that case - though I can't imagine this is intended behavior.
There appear to be other cases where count() does not work correctly with custom statement, so this might not be limited to left joins:
https://www.typo3.net/forum/thematik/zeige/thema/108484/