From cd9c1c749f9d135fa31d012f4e880d364228320e Mon Sep 17 00:00:00 2001 From: William Allen Date: Mon, 16 Nov 2026 11:15:01 -0500 Subject: [PATCH] Cap `queryTests` at 50k tests Unless a `limit` was given, queryTests loaded every matching test, so a busy day could exceed PHP's default 512 MB memory limit. It now lists at most 50,000 tests, and a missing or higher `limit` is reduced to that. --- app/cdash/app/Controller/Api/QueryTests.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/cdash/app/Controller/Api/QueryTests.php b/app/cdash/app/Controller/Api/QueryTests.php index cf8998dde9..c7f39155fd 100644 --- a/app/cdash/app/Controller/Api/QueryTests.php +++ b/app/cdash/app/Controller/Api/QueryTests.php @@ -27,6 +27,9 @@ class QueryTests extends ResultsApi { + // Listing every test of a busy day can exceed PHP's memory limit. + private const MAX_TESTS = 50000; + public function __construct(Database $db, Project $project) { parent::__construct($db, $project); @@ -219,6 +222,8 @@ public function getResponse(): array unset($filterdata['xml']); $response['filterdata'] = $filterdata; $this->setFilterData($filterdata); + $limit = $filterdata['limit']; + $this->limitSQL = ' LIMIT ' . (is_int($limit) && $limit > 0 ? min($limit, self::MAX_TESTS) : self::MAX_TESTS); $response['filterurl'] = get_filterurl(); // Menu