Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
72.22% |
13 / 18 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
PageStabilityProtectForm | |
72.22% |
13 / 18 |
|
0.00% |
0 / 2 |
5.54 | |
0.00% |
0 / 1 |
reallyDoPreloadParameters | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
2 | |||
reallyDoCheckParameters | |
92.86% |
13 / 14 |
|
0.00% |
0 / 1 |
4.01 |
1 | <?php |
2 | |
3 | use MediaWiki\MediaWikiServices; |
4 | |
5 | // Assumes $wgFlaggedRevsProtection is on |
6 | class PageStabilityProtectForm extends PageStabilityForm { |
7 | protected function reallyDoPreloadParameters() { |
8 | $oldConfig = $this->getOldConfig(); |
9 | $this->autoreview = $oldConfig['autoreview']; // protect level |
10 | $this->watchThis = MediaWikiServices::getInstance()->getWatchlistManager() |
11 | ->isWatched( $this->getUser(), $this->title ); |
12 | } |
13 | |
14 | protected function reallyDoCheckParameters() { |
15 | $oldConfig = $this->getOldConfig(); |
16 | # Autoreview only when protecting currently unprotected pages |
17 | $this->reviewThis = ( FRPageConfig::getProtectionLevel( $oldConfig ) == 'none' ); |
18 | # Autoreview restriction => use stable |
19 | # No autoreview restriction => site default |
20 | $this->override = ( $this->autoreview != '' ) |
21 | ? 1 // edits require review before being published |
22 | : (int)FlaggedRevs::isStableShownByDefault(); // site default |
23 | # Check that settings are a valid protection level... |
24 | $newConfig = [ |
25 | 'override' => $this->override, |
26 | 'autoreview' => $this->autoreview |
27 | ]; |
28 | if ( FRPageConfig::getProtectionLevel( $newConfig ) == 'invalid' ) { |
29 | return 'stabilize_invalid_level'; // double-check configuration |
30 | } |
31 | # Check autoreview restriction setting |
32 | if ( !FlaggedRevs::userCanSetAutoreviewLevel( $this->user, $this->autoreview ) ) { |
33 | return 'stabilize_denied'; // invalid value |
34 | } |
35 | return true; |
36 | } |
37 | } |