Skip to content

Commit 0460af2

Browse files
Fix HTTP 500 error for testOverview + filters timeline (backport to 3.2) (#2022)
1 parent 4aeeb61 commit 0460af2

3 files changed

Lines changed: 3 additions & 136 deletions

File tree

app/cdash/app/Controller/Api/Timeline.php

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ public function getResponse()
5959
{
6060
$this->filterdata = json_decode(request()->input('filterdata'), true);
6161
$page = htmlentities($this->filterdata['pageId']);
62-
$this->filterSQL = generate_filterdata_sql($this->filterdata);
6362
$this->generateColorMap();
6463

6564
$this->project->Fill();
@@ -70,8 +69,6 @@ public function getResponse()
7069
switch ($page) {
7170
case 'buildProperties.php':
7271
return $this->chartForBuildProperties();
73-
case 'index.php':
74-
return $this->chartForIndex();
7572
case 'testOverview.php':
7673
return $this->chartForTestOverview();
7774
case 'viewBuildGroup.php':
@@ -141,43 +138,6 @@ private function chartForBuildProperties()
141138
return $this->getTimelineChartData($stmt);
142139
}
143140

144-
private function chartForIndex()
145-
{
146-
$this->defectTypes = [
147-
[
148-
'name' => 'builderrors',
149-
'prettyname' => 'Errors',
150-
],
151-
[
152-
'name' => 'testfailed',
153-
'prettyname' => 'Test Failures',
154-
]
155-
];
156-
157-
// Query for defects on expected builds only.
158-
$stmt = $this->db->prepare("
159-
SELECT b.id, b.starttime, b.builderrors, b.buildwarnings, b.testfailed
160-
FROM build b
161-
JOIN build2group b2g ON b2g.buildid = b.id
162-
JOIN build2grouprule b2gr ON
163-
b2g.groupid = b2gr.groupid AND b2gr.buildtype = b.type AND
164-
b2gr.buildname = b.name AND b2gr.siteid = b.siteid
165-
WHERE b.projectid = :projectid AND b.parentid IN (0, -1)
166-
AND b2gr.expected = 1
167-
$this->filterSQL
168-
ORDER BY starttime");
169-
if (!pdo_execute($stmt, [':projectid' => $this->project->Id])) {
170-
abort(500, 'Failed to load results');
171-
}
172-
$response = $this->getTimelineChartData($stmt);
173-
$response['colors'] = [
174-
$this->colors[self::CLEAN],
175-
$this->colors[self::FAILURE],
176-
$this->colors[self::ERROR]
177-
];
178-
return $response;
179-
}
180-
181141
private function chartForTestOverview()
182142
{
183143
$this->defectTypes = [
@@ -199,7 +159,6 @@ private function chartForTestOverview()
199159
SELECT b.id, b.starttime, b.testfailed, b.testnotrun, b.testpassed
200160
FROM build b
201161
WHERE b.projectid = :projectid AND b.parentid IN (0, -1)
202-
$this->filterSQL
203162
ORDER BY starttime");
204163
if (!pdo_execute($stmt, [':projectid' => $this->project->Id])) {
205164
abort(500, 'Failed to load results');

app/cdash/tests/test_timeline.php

Lines changed: 1 addition & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,9 @@ public function testTimeline()
7777
$this->toggle_expected($client, $build, 1);
7878

7979
// Now that we have an expected build, validate timeline data on relevant pages.
80-
$pages_to_check = ['index.php', 'testOverview.php', 'viewBuildGroup.php'];
80+
$pages_to_check = ['testOverview.php', 'viewBuildGroup.php'];
8181

8282
$answer_key = [
83-
'index.php' => [
84-
'Test Failures' => 1
85-
],
8683
'testOverview.php' => [
8784
'Failing Tests' => 1,
8885
'Not Run Tests' => 1,
@@ -107,85 +104,6 @@ public function testTimeline()
107104
$this->toggle_expected($client, $build, 0);
108105
}
109106

110-
public function testTimelineWithFilters()
111-
{
112-
// Find the three builds we will use for this test case.
113-
$builds = [];
114-
$this->get($this->url . '/api/v1/index.php?project=InsightExample&date=2010-07-07');
115-
$content = $this->getBrowser()->getContent();
116-
$jsonobj = json_decode($content, true);
117-
foreach ($jsonobj['buildgroups'] as $buildgroup_response) {
118-
foreach ($buildgroup_response['builds'] as $build_response) {
119-
$build = new Build();
120-
$build->Id = $build_response['id'];
121-
$build->FillFromId($build->Id);
122-
$builds[] = $build;
123-
}
124-
}
125-
$num_builds = count($builds);
126-
if ($num_builds != 3) {
127-
$this->fail("Expected 3 builds, found $num_builds");
128-
}
129-
130-
// Login as admin.
131-
$client = $this->getGuzzleClient();
132-
133-
// Mark these builds as expected.
134-
foreach ($builds as $build) {
135-
$this->toggle_expected($client, $build, 1);
136-
}
137-
138-
// Validate timeline with filters.
139-
$filterdata_arr = [
140-
'hasdateclause' => 0,
141-
'filtercombine' => 'and',
142-
'filtercount' => 1,
143-
'limit' => 0,
144-
'filters' => [
145-
[
146-
'field' => 'buildname',
147-
'compare' => 63,
148-
'value' => 'vs'
149-
]
150-
],
151-
];
152-
153-
$pages_to_check = ['index.php', 'testOverview.php', 'viewBuildGroup.php'];
154-
155-
$answer_key = [
156-
'index.php' => [
157-
'Errors' => 1,
158-
'Test Failures' => 2
159-
],
160-
'testOverview.php' => [
161-
'Failing Tests' => 2,
162-
'Not Run Tests' => 2,
163-
'Passing Tests' => 2
164-
],
165-
'viewBuildGroup.php' => [
166-
'Errors' => 1,
167-
'Test Failures' => 2
168-
],
169-
];
170-
171-
foreach ($pages_to_check as $page) {
172-
$filterdata_arr['pageId'] = $page;
173-
$filterdata = json_encode($filterdata_arr);
174-
$extra_param = $page == 'viewBuildGroup.php' ? '&buildgroup=Nightly' : '';
175-
$this->get($this->url . "/api/v1/timeline.php?date=2010-07-07&filterdata=$filterdata&project=InsightExample$extra_param");
176-
$content = $this->getBrowser()->getContent();
177-
$jsonobj = json_decode($content, true);
178-
179-
$this->validateExtent(1278464400000, 1278550800000, $jsonobj);
180-
$this->validatePage($answer_key, $page, 1278464400000, $jsonobj);
181-
}
182-
183-
// Revert back to unexpected.
184-
foreach ($builds as $build) {
185-
$this->toggle_expected($client, $build, 0);
186-
}
187-
}
188-
189107
private function validateExtent($start, $end, $jsonobj)
190108
{
191109
if ($jsonobj['extentstart'] != $start) {

phpstan-baseline.neon

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2835,15 +2835,15 @@ parameters:
28352835

28362836
-
28372837
message: "#^Access to an undefined property CDash\\\\Controller\\\\Api\\\\Timeline\\:\\:\\$colors\\.$#"
2838-
count: 12
2838+
count: 9
28392839
path: app/cdash/app/Controller/Api/Timeline.php
28402840

28412841
-
28422842
message: """
28432843
#^Call to deprecated function pdo_execute\\(\\)\\:
28442844
v2\\.5\\.0 01/22/2018$#
28452845
"""
2846-
count: 4
2846+
count: 3
28472847
path: app/cdash/app/Controller/Api/Timeline.php
28482848

28492849
-
@@ -2866,11 +2866,6 @@ parameters:
28662866
count: 1
28672867
path: app/cdash/app/Controller/Api/Timeline.php
28682868

2869-
-
2870-
message: "#^Method CDash\\\\Controller\\\\Api\\\\Timeline\\:\\:chartForIndex\\(\\) has no return type specified\\.$#"
2871-
count: 1
2872-
path: app/cdash/app/Controller/Api/Timeline.php
2873-
28742869
-
28752870
message: "#^Method CDash\\\\Controller\\\\Api\\\\Timeline\\:\\:chartForTestOverview\\(\\) has no return type specified\\.$#"
28762871
count: 1
@@ -25343,11 +25338,6 @@ parameters:
2534325338
count: 1
2534425339
path: app/cdash/tests/test_timeline.php
2534525340

25346-
-
25347-
message: "#^Method TimelineTestCase\\:\\:testTimelineWithFilters\\(\\) has no return type specified\\.$#"
25348-
count: 1
25349-
path: app/cdash/tests/test_timeline.php
25350-
2535125341
-
2535225342
message: "#^Method TimelineTestCase\\:\\:toggle_expected\\(\\) has no return type specified\\.$#"
2535325343
count: 1

0 commit comments

Comments
 (0)