Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 7 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
SpecialRecordImpression | |
0.00% |
0 / 7 |
|
0.00% |
0 / 3 |
20 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
execute | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
sendHeaders | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
6 |
1 | <?php |
2 | /** |
3 | * Null endpoint. This is a workaround to simplify analytics. |
4 | */ |
5 | class SpecialRecordImpression extends UnlistedSpecialPage { |
6 | // Cache this blank response for a day or so (60 * 60 * 24 s.) |
7 | public const CACHE_EXPIRY = 86400; |
8 | |
9 | public function __construct() { |
10 | // Register special page |
11 | parent::__construct( "RecordImpression" ); |
12 | } |
13 | |
14 | public function execute( $par ) { |
15 | $this->getOutput()->disable(); |
16 | |
17 | $this->sendHeaders(); |
18 | |
19 | // Output nothing else. |
20 | } |
21 | |
22 | /** |
23 | * Generate the HTTP response headers for the banner file |
24 | */ |
25 | private function sendHeaders() { |
26 | $expiry = static::CACHE_EXPIRY; |
27 | header( "Content-Type: image/png" ); |
28 | |
29 | // If we have a logged in user; do not cache (default for special pages) |
30 | // lest we capture a set-cookie header. Otherwise cache so we don't have |
31 | // too big of a DDoS hole. |
32 | if ( !$this->getUser()->isRegistered() ) { |
33 | header( "Cache-Control: public, s-maxage={$expiry}, max-age=0" ); |
34 | } |
35 | } |
36 | } |