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 #1

Updated by Kochin Chang about 1 year ago

I should also mention that removing ->groupBy('summary') seems to resolve the issue.

Actions #2

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

Actions #3

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

Actions #4

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.

Actions #5

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

Actions #6

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

Actions #7

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

Actions #8

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

Actions #9

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

Actions #10

Updated by Oliver Hader about 1 year ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100
Actions #11

Updated by Benni Mack 5 months ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF