Bug #101913
closedSQLSTATE[42803]: Grouping error: 7 ERROR: column "sys_http_report.uuid" must appear in the GROUP BY clause or be used in an aggregate function
100%
Description
The administration log this error message after turning on the Content Security Policy:
Core: Exception handler (WEB): Uncaught TYPO3 Exception: #7: An exception occurred while executing a query: SQLSTATE[42803]: Grouping error: 7 ERROR: column "sys_http_report.uuid" must appear in the GROUP BY clause or be used in an aggregate function LINE 1: ... * FROM "sys_http_report" WHERE "uuid" IN (SELECT "uuid" FRO... ^ | Doctrine\DBAL\Exception\DriverException thrown in file /var/www/TYPO3/vendor/doctrine/dbal/src/Driver/API/PostgreSQL/ExceptionConverter.php in line 87. Requested URL: http://cms/typo3/ajax/security/csp/control?token=--AnonymizedToken-- \
And the PostgreSQL log shows:
ERROR: column "sys_http_report.uuid" must appear in the GROUP BY clause or be used in an aggregate function at character 57 STATEMENT: SELECT * FROM "sys_http_report" WHERE "uuid" IN (SELECT "uuid" FROM "sys_http_report" WHERE ("type" = $1) AND ("status" = $2) GROUP BY "summary" ORDER BY "created" desc) ORDER BY "created" desc
The PHP code for this was found in the file vendor/typo3/cms-core/Classes/Security/ContentSecurityPolicy/Reporting/ReportRepository.php.
/**
* @return list<SummarizedReport>
*/
public function findAllSummarized(ReportDemand $demand = null): array
{
$demand ??= ReportDemand::create();
$queryBuilder = $this->prepareQueryBuilder($demand);
$subQueryBuilder = $this->prepareQueryBuilder($demand, $queryBuilder)
->select('uuid')
->groupBy('summary');
$result = $queryBuilder
->select('*')
->where($queryBuilder->expr()->in('uuid', $subQueryBuilder->getSQL()))
->executeQuery();
$summaryCountMap = $this->fetchSummaryCountMap();
return array_map(
static fn (array $row) => SummarizedReport::fromArray($row)
->withCount($summaryCountMap[$row['summary']] ?? 0),
$result->fetchAllAssociative()
);
}
Updated by Kochin Chang about 1 year ago
I should also mention that removing ->groupBy('summary') seems to resolve the issue.
Updated by Gerrit Code Review about 1 year ago
- Status changed from New to Under Review
Patch set 1 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/81015
Updated by Gerrit Code Review about 1 year ago
Patch set 2 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/81015
Updated by Kochin Chang about 1 year ago
I replaced the file vendor/typo3/cms-core/Classes/Security/ContentSecurityPolicy/Reporting/ReportRepository.php with the patched version. So far there is no error popped up. This is not a thorough test.
Updated by Gerrit Code Review about 1 year ago
Patch set 3 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/81015
Updated by Gerrit Code Review about 1 year ago
Patch set 4 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/81015
Updated by Gerrit Code Review about 1 year ago
Patch set 5 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/81015
Updated by Gerrit Code Review about 1 year ago
Patch set 6 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/81015
Updated by Gerrit Code Review about 1 year ago
Patch set 1 for branch 12.4 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/81435
Updated by Oliver Hader about 1 year ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset 0d6719c5c0ce639c72cdbb6861616d48d2e6b109.