Skip to content

Commit 86abf43

Browse files
authored
Merge pull request #3145 from catchpoint/master
Promote to prod
2 parents ea8af77 + 1c3e17f commit 86abf43

File tree

3 files changed

+446
-432
lines changed

3 files changed

+446
-432
lines changed

www/common.inc

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ if (Util::getSetting('cp_auth')) {
4242
error_log($e->getMessage());
4343
$route = "/";
4444
$message = "There was a problem with you account. Please reach out to customer service." .
45-
"Error number: 2000";
45+
"Error number: 2000";
4646

4747
$host = Util::getSetting('host');
4848
if (Util::getSetting('php_sessions')) {
@@ -65,7 +65,7 @@ if (Util::getSetting('cp_auth')) {
6565
$message = "";
6666
if (is_a($e, PortalException::class)) {
6767
$message = "There was a problem with you account. Please reach out to customer service." .
68-
"Error number: {$e->getErrorNumber()}";
68+
"Error number: {$e->getErrorNumber()}";
6969
} else {
7070
$message = $e->getMessage();
7171
}
@@ -375,7 +375,7 @@ if ($supportsAuth && $supportsCPAuth) {
375375
require_once INCLUDES_PATH . '/common/AttachUser.php';
376376
require_once INCLUDES_PATH . '/common/AttachSignupClient.php';
377377
require_once INCLUDES_PATH . '/common/AttachBannerMessageManager.php';
378-
// require_once INCLUDES_PATH . '/common/CheckCSRF.php';
378+
// require_once INCLUDES_PATH . '/common/CheckCSRF.php';
379379
}
380380

381381
// Load the test-specific data
@@ -531,7 +531,7 @@ if (strlen($id)) {
531531
$controlTestUrlGenerator = UrlGenerator::create(FRIENDLY_URLS, "", $metaInfo['experiment']['control_id'], 0, 0);
532532
$controlTestHref = $controlTestUrlGenerator->resultSummary();
533533

534-
$experimentResultsHref = "/video/compare.php?tests=" . $id . ',' . $metaInfo['experiment']['control_id'];
534+
$experimentResultsHref = "/video/compare.php?tests=" . $id . ',' . $metaInfo['experiment']['control_id'] . ($req_fp ? "&fp=1" : '');
535535
$experimentTestHref = "/result/" . $id;
536536

537537
$experimentOptsUrlGenerator = UrlGenerator::create(FRIENDLY_URLS, "", $id, 0, 0);
@@ -567,5 +567,6 @@ if (is_file(SETTINGS_PATH . '/custom_common.inc.php')) {
567567
require_once INCLUDES_PATH . '/experiments/user_access.inc';
568568

569569
$request_context->setReadOnly(
570-
!is_null($request_context->getUser()) && $request_context->getUser() && $request_context->getUser()->newPortalExperience()
570+
isset($req_fp) ||
571+
!is_null($request_context->getUser()) && $request_context->getUser() && $request_context->getUser()->newPortalExperience()
571572
);

www/include/UrlGenerator.php

Lines changed: 105 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,29 @@ abstract class UrlGenerator
1414
protected $step;
1515
protected $baseUrl;
1616
protected $testId;
17+
protected $fp;
1718

1819
protected function __construct($baseUrl, $testId, $run, $cached, $step = 1)
1920
{
21+
global $req_fp;
22+
2023
$this->baseUrl = rtrim(strval($baseUrl), "/");
2124
$this->testId = $testId;
2225
$this->run = intval($run);
2326
$this->cached = $cached ? true : false;
2427
$this->step = $step;
28+
$this->fp = $req_fp;
2529
}
2630

27-
/**
28-
* @param bool $friendlyUrls If the URL should be friendly (via mod_rewrite) or standard
29-
* @param string $baseUrl URL base for the server (like http://my.wpt.server)
30-
* @param string $testId ID of the test
31-
* @param int $run Run number
32-
* @param bool $cached True if cached run, false otherwise
33-
* @param int $step The step number (1 by default)
34-
* @return FriendlyUrlGenerator|StandardUrlGenerator A UrlGenerator for friendly or standard URLs
35-
*/
31+
/**
32+
* @param bool $friendlyUrls If the URL should be friendly (via mod_rewrite) or standard
33+
* @param string $baseUrl URL base for the server (like http://my.wpt.server)
34+
* @param string $testId ID of the test
35+
* @param int $run Run number
36+
* @param bool $cached True if cached run, false otherwise
37+
* @param int $step The step number (1 by default)
38+
* @return FriendlyUrlGenerator|StandardUrlGenerator A UrlGenerator for friendly or standard URLs
39+
*/
3640
public static function create($friendlyUrls, $baseUrl, $testId, $run, $cached, $step = 1)
3741
{
3842
if ($friendlyUrls) {
@@ -42,127 +46,132 @@ public static function create($friendlyUrls, $baseUrl, $testId, $run, $cached, $
4246
}
4347
}
4448

45-
/**
46-
* @param string $page Result page to generate the URL for
47-
* @param string $extraParams|null Extra parameters to append (without '?' or '&' at start)
48-
* @return string The generated URL
49-
*/
49+
/**
50+
* @param string $page Result page to generate the URL for
51+
* @param string $extraParams|null Extra parameters to append (without '?' or '&' at start)
52+
* @return string The generated URL
53+
*/
5054
abstract public function resultPage($page, $extraParams = null);
5155

52-
/**
53-
* @param string $image Image name to generate the thumbnail URL for
54-
* @return string The generated URL
55-
*/
56+
/**
57+
* @param string $image Image name to generate the thumbnail URL for
58+
* @return string The generated URL
59+
*/
5660
abstract public function thumbnail($image);
5761

58-
/**
59-
* @param string $image Generated image name to generate the URL for
60-
* @return string The generated URL
61-
*/
62+
/**
63+
* @param string $image Generated image name to generate the URL for
64+
* @return string The generated URL
65+
*/
6266
abstract public function generatedImage($image);
6367

64-
/**
65-
* @param bool $connectionView True for a connection view waterfall, false for the normal one.
66-
* @param int $width Width of the generated image
67-
* @param bool $withMime True if MIME data should be generated, false otherwise
68-
* @return string The generated URL
69-
*/
68+
/**
69+
* @param bool $connectionView True for a connection view waterfall, false for the normal one.
70+
* @param int $width Width of the generated image
71+
* @param bool $withMime True if MIME data should be generated, false otherwise
72+
* @return string The generated URL
73+
*/
7074
abstract public function waterfallImage($connectionView, $width, $withMime);
7175

72-
/**
73-
* @param string $extraParams|null Extra parameters to append (without '?' or '&' at start)
74-
* @return string The generated URL
75-
*/
76+
/**
77+
* @param string $extraParams|null Extra parameters to append (without '?' or '&' at start)
78+
* @return string The generated URL
79+
*/
7680
abstract public function resultSummary($extraParams = null);
7781

78-
/**
79-
* @return string The generated URL
80-
*/
82+
/**
83+
* @return string The generated URL
84+
*/
8185
abstract public function optimizationChecklistImage();
8286

83-
/**
84-
* @param string $file The name of the file to get with the URL
85-
* @param string $video If it's a video-related file, this can be set to the corresponding video directory name
86-
* @return string The generated URL
87-
*/
87+
/**
88+
* @param string $file The name of the file to get with the URL
89+
* @param string $video If it's a video-related file, this can be set to the corresponding video directory name
90+
* @return string The generated URL
91+
*/
8892
public function getFile($file, $video = "")
8993
{
9094
$videoParam = $video ? "&video=" . $video : "";
9195
$url = $this->baseUrl . "/getfile.php?test=" . $this->testId . $videoParam . "&file=" . $file;
9296
return $url;
9397
}
9498

95-
/**
96-
* @param string $file The name of the file to get with the URL
97-
* @return string The generated URL
98-
*/
99+
/**
100+
* @param string $file The name of the file to get with the URL
101+
* @return string The generated URL
102+
*/
99103
public function getGZip($file)
100104
{
101105
$compressedParam = (substr($file, -3) == ".gz") ? "&compressed=1" : "";
102106
$url = $this->baseUrl . "/getgzip.php?test=" . $this->testId . $compressedParam . "&file=" . $file;
103107
return $url;
104108
}
105109

106-
/**
107-
* @param string|int $requestNumber The request number to identify the response body
108-
* @return string The generated URL
109-
*/
110+
/**
111+
* @param string|int $requestNumber The request number to identify the response body
112+
* @return string The generated URL
113+
*/
110114
public function responseBodyWithRequestNumber($requestNumber)
111115
{
112-
return $this->baseUrl . "/response_body.php?" . $this->urlParams() . "&request=" . strval($requestNumber);
116+
$fpParam = $this->fp ? "&fp=$this->fp" : "";
117+
return $this->baseUrl . "/response_body.php?" . $this->urlParams() . "&request=" . strval($requestNumber) . $fpParam;
113118
}
114119

115-
/**
116-
* @param int $bodyId The body ID to identify the response body
117-
* @return string The generated URL
118-
*/
120+
/**
121+
* @param int $bodyId The body ID to identify the response body
122+
* @return string The generated URL
123+
*/
119124
public function responseBodyWithBodyId($bodyId)
120125
{
121-
return $this->baseUrl . "/response_body.php?" . $this->urlParams() . "&bodyid=" . strval($bodyId);
126+
$fpParam = $this->fp ? "&fp=$this->fp" : "";
127+
return $this->baseUrl . "/response_body.php?" . $this->urlParams() . "&bodyid=" . strval($bodyId) . $fpParam;
122128
}
123129

124-
/**
125-
* @param string $end Optional. A specific "end" to use for video creation
126-
* @return string The generated URL to create a video
127-
*/
130+
/**
131+
* @param string $end Optional. A specific "end" to use for video creation
132+
* @return string The generated URL to create a video
133+
*/
128134
public function createVideo($end = null)
129135
{
130136
$tests = $this->testId . "-r:" . $this->run . "-c:" . ($this->cached ? 1 : 0);
131137
$tests .= ($this->step > 1) ? ("-s:" . $this->step) : "";
132138
$tests .= $end ? "-e:$end" : "";
139+
$tests .= $this->fp ? "&fp=$this->fp" : "";
133140
return $this->baseUrl . "/video/view.php?tests=" . $tests;
134141
}
135142

136-
/**
137-
* @param string $end Optional. A specific "end" to use for filmstrip view
138-
* @return string The generated URL for the filmstrip view
139-
*/
143+
/**
144+
* @param string $end Optional. A specific "end" to use for filmstrip view
145+
* @return string The generated URL for the filmstrip view
146+
*/
140147
public function filmstripView($end = null)
141148
{
142149
$tests = $this->testId . "-r:" . $this->run . "-c:" . ($this->cached ? 1 : 0);
143150
$tests .= ($this->step > 1) ? ("-s:" . $this->step) : "";
144151
$tests .= $end ? "-e:$end" : "";
152+
$tests .= $this->fp ? "&fp=$this->fp" : "";
145153
return $this->baseUrl . "/video/compare.php?tests=" . $tests;
146154
}
147155

148156

149-
/**
150-
* @param string $end Optional. A specific "end" to use for filmstrip view
151-
* @return string The generated URL for the filmstrip view
152-
*/
157+
/**
158+
* @param string $end Optional. A specific "end" to use for filmstrip view
159+
* @return string The generated URL for the filmstrip view
160+
*/
153161
public function filmstripImage($end = null)
154162
{
155163
$tests = $this->testId . "-r:" . $this->run . "-c:" . ($this->cached ? 1 : 0);
156164
$tests .= ($this->step > 1) ? ("-s:" . $this->step) : "";
157165
$tests .= $end ? "-e:$end" : "";
166+
$tests .= $this->fp ? "&fp=$this->fp" : "";
158167
return $this->baseUrl . "/video/filmstrip.php?tests=" . $tests;
159168
}
160169

161-
/**
162-
* @param string $frame The thumbnail name
163-
* @param int $fit Maximum size of the thumbnail
164-
* @return string The URL for a thumbnail of the video frame
165-
*/
170+
/**
171+
* @param string $frame The thumbnail name
172+
* @param int $fit Maximum size of the thumbnail
173+
* @return string The URL for a thumbnail of the video frame
174+
*/
166175
public function videoFrameThumbnail($frame, $fit, $options = null)
167176
{
168177
$file = "video_" . rtrim(strtolower($this->underscorePrefix()), "_") . "/" . $frame;
@@ -173,19 +182,19 @@ public function videoFrameThumbnail($frame, $fit, $options = null)
173182
return $url;
174183
}
175184

176-
/**
177-
* @return string The generated URL to download all video frames
178-
*/
185+
/**
186+
* @return string The generated URL to download all video frames
187+
*/
179188
public function downloadVideoFrames()
180189
{
181190
return $this->baseUrl . "/video/downloadFrames.php?" . $this->urlParams();
182191
}
183192

184-
/**
185-
* @param string $page Step-independent Result page to generate the URL for
186-
* @param string $extraParams|null Extra parameters to append (without '?' or '&' at start)
187-
* @return string The generated URL
188-
*/
193+
/**
194+
* @param string $page Step-independent Result page to generate the URL for
195+
* @param string $extraParams|null Extra parameters to append (without '?' or '&' at start)
196+
* @return string The generated URL
197+
*/
189198
public function stepDetailPage($page, $extraParams = null)
190199
{
191200
$extraParams = $extraParams ? ("&" . $extraParams) : "";
@@ -201,7 +210,8 @@ protected function underscorePrefix()
201210
protected function urlParams()
202211
{
203212
$stepParam = $this->step > 1 ? ("&step=" . $this->step) : "";
204-
return "test=" . $this->testId . "&run=" . $this->run . ($this->cached ? "&cached=1" : "") . $stepParam;
213+
$fpParam = $this->fp ? "&fp=$this->fp" : "";
214+
return "test=" . $this->testId . "&run=" . $this->run . ($this->cached ? "&cached=1" : "") . $stepParam . $fpParam;
205215
}
206216
}
207217

@@ -213,6 +223,7 @@ public function resultPage($page, $extraParams = null)
213223
if ($this->cached) {
214224
$url .= "cached/";
215225
}
226+
$extraParams = $this->prepareExtraParams($extraParams);
216227
if ($extraParams != null) {
217228
$url .= "?" . $extraParams;
218229
}
@@ -241,7 +252,7 @@ public function generatedImage($image)
241252
{
242253
$parts = explode("_", $this->testId);
243254
$testPath = substr($parts[0], 0, 2) . "/" . substr($parts[0], 2, 2) . "/" . substr($parts[0], 4, 2) .
244-
"/" . $parts[1];
255+
"/" . $parts[1];
245256
if (sizeof($parts) > 2) {
246257
$testPath .= "/" . $parts[2];
247258
}
@@ -251,6 +262,7 @@ public function generatedImage($image)
251262
public function resultSummary($extraParams = null)
252263
{
253264
$url = $this->baseUrl . "/result/" . $this->testId . "/";
265+
$extraParams = $this->prepareExtraParams($extraParams);
254266
if ($extraParams != null) {
255267
$url .= "?" . $extraParams;
256268
}
@@ -269,6 +281,17 @@ public function optimizationChecklistImage()
269281
{
270282
return $this->generatedImage("optimization");
271283
}
284+
285+
private function prepareExtraParams($extraParams = null)
286+
{
287+
if (!$this->fp) {
288+
return $extraParams;
289+
}
290+
291+
return $extraParams
292+
? ("fp=$this->fp&" . $extraParams)
293+
: "fp=$this->fp";
294+
}
272295
}
273296

274297
class StandardUrlGenerator extends UrlGenerator
@@ -298,6 +321,7 @@ public function generatedImage($image)
298321
public function resultSummary($extraParams = null)
299322
{
300323
$extraParams = $extraParams ? ("&" . $extraParams) : "";
324+
$extraParams .= $this->fp ? "&fp=$this->fp" : "";
301325
return $this->baseUrl . "/results.php?test=" . $this->testId . $extraParams;
302326
}
303327

0 commit comments

Comments
 (0)