Project

General

Profile

Actions

Bug #101913

closed

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

Added by Kochin Chang about 1 year ago. Updated 5 months ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
-
Target version:
-
Start date:
2023-09-13
Due date:
% Done:

100%

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

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()
        );
    }

Actions

Also available in: Atom PDF