Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 26 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
ApiWikimediaEventsBlockedEdit | |
0.00% |
0 / 26 |
|
0.00% |
0 / 3 |
20 | |
0.00% |
0 / 1 |
execute | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
6 | |||
getAllowedParams | |
0.00% |
0 / 19 |
|
0.00% |
0 / 1 |
2 | |||
isInternal | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | |
3 | namespace WikimediaEvents; |
4 | |
5 | use MediaWiki\Api\ApiBase; |
6 | use MediaWiki\Title\Title; |
7 | use Wikimedia\ParamValidator\ParamValidator; |
8 | |
9 | class ApiWikimediaEventsBlockedEdit extends ApiBase { |
10 | |
11 | /** |
12 | * @inheritDoc |
13 | */ |
14 | public function execute() { |
15 | $user = $this->getUser(); |
16 | $params = $this->extractRequestParams(); |
17 | $title = Title::newFromText( $params['page'] ); |
18 | |
19 | if ( !$title ) { |
20 | $this->dieWithError( [ 'apierror-invalidtitle', wfEscapeWikiText( $params['page'] ) ] ); |
21 | } |
22 | |
23 | BlockUtils::logBlockedEditAttempt( $user, $title, $params['interface'], $params['platform'] ); |
24 | } |
25 | |
26 | /** |
27 | * @inheritDoc |
28 | */ |
29 | public function getAllowedParams() { |
30 | return [ |
31 | 'page' => [ |
32 | ParamValidator::PARAM_REQUIRED => true, |
33 | ], |
34 | 'interface' => [ |
35 | ParamValidator::PARAM_REQUIRED => true, |
36 | |
37 | // See https://gerrit.wikimedia.org/g/schemas/event/secondary/+/192e1a497d16b3da22817177e7676e342a4494a7/jsonschema/analytics/mediawiki/editattemptsblocked/current.yaml#44 |
38 | ParamValidator::PARAM_TYPE => [ |
39 | 'wikieditor', |
40 | 'visualeditor', |
41 | 'mobilefrontend', |
42 | 'discussiontools', |
43 | 'other', |
44 | ], |
45 | ], |
46 | 'platform' => [ |
47 | ParamValidator::PARAM_REQUIRED => true, |
48 | ParamValidator::PARAM_TYPE => [ 'desktop', 'mobile' ], |
49 | ], |
50 | ]; |
51 | } |
52 | |
53 | /** |
54 | * @inheritDoc |
55 | */ |
56 | public function isInternal() { |
57 | return true; |
58 | } |
59 | |
60 | } |