Project

General

Profile

Actions

Bug #103427

closed

DatabaseRecordList::getTables() generates an invalid `COUNT()` query in some cirumstances

Added by Stefan Bürk 8 months ago. Updated 5 months ago.

Status:
Closed
Priority:
Should have
Assignee:
Category:
-
Target version:
-
Start date:
2024-03-19
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
11
PHP Version:
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

\TYPO3\CMS\Backend\RecordList\DatabaseRecordList provides the ability
to modify the QueryBuilder used for the record list representation with
the PSR-14 ModifyDatabaseQueryForRecordListingEvent , after generic
query informations like default orderings and similar has been added.

That is coverd within the `getQueryBuilder()` method, which is used in
other class methods, for example in `getTables()` where it is changed
to a `COUNT` query.

MariaDB for example is picky about count queries using `order by`,
`group by` or aggretation methods which are not reflected or added
in the counter parts leading to a not so use-full error like

  Mixing of GROUP columns (MIN(),MAX(),COUNT(),...) with no GROUP
  columns is illegal if there is no GROUP BY clause

or similar variants.

This may be adjusted to some extend with server configurations, but
cannot be expected. TYPO3 core must generate valid queries valid
for all database vendor and flavours.

Building up a generic `SELECT` query and reusing it as simple `COUNT`
query requires to avoid the `ORDER BY` and `GROUP BY` and needs to
be removed. Other places throughout the TYPO3 core already does this.

An exception occurred while executing
'
  SELECT COUNT(*) FROM `static_countries`
  WHERE (`static_countries`.`pid` = ?) AND (`static_countries`.`deleted` = 0)
  ORDER BY `cn_short_de` ASC LIMIT 1
' with params [14516]: Mixing of GROUP columns (MIN(),MAX(),COUNT(),...) with
no GROUP columns is illegal if there is no GROUP BY clause
Actions

Also available in: Atom PDF