Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
38.10% |
8 / 21 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
SpecialMobileDiff | |
38.10% |
8 / 21 |
|
0.00% |
0 / 3 |
18.62 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getDesktopUrl | |
88.89% |
8 / 9 |
|
0.00% |
0 / 1 |
4.02 | |||
execute | |
0.00% |
0 / 11 |
|
0.00% |
0 / 1 |
6 |
1 | <?php |
2 | |
3 | use MediaWiki\SpecialPage\UnlistedSpecialPage; |
4 | |
5 | /** |
6 | * Show the difference between two revisions of a page |
7 | */ |
8 | class SpecialMobileDiff extends UnlistedSpecialPage { |
9 | public function __construct() { |
10 | parent::__construct( 'MobileDiff' ); |
11 | } |
12 | |
13 | /** |
14 | * Get the URL for Desktop version of difference view |
15 | * @param string|null $subPage URL of mobile diff page |
16 | * @return string|null Url to mobile diff page |
17 | */ |
18 | public function getDesktopUrl( $subPage ) { |
19 | if ( $subPage === null ) { |
20 | return null; |
21 | } |
22 | $parts = explode( '...', $subPage ); |
23 | if ( count( $parts ) > 1 ) { |
24 | $params = [ 'diff' => $parts[1], 'oldid' => $parts[0] ]; |
25 | } else { |
26 | $params = [ 'diff' => $parts[0] ]; |
27 | } |
28 | if ( $this->getRequest()->getVal( 'unhide' ) ) { |
29 | $params['unhide'] = 1; |
30 | } |
31 | return wfAppendQuery( wfScript(), $params ); |
32 | } |
33 | |
34 | /** |
35 | * @inheritDoc |
36 | */ |
37 | public function execute( $subPage ) { |
38 | $out = $this->getOutput(); |
39 | if ( !$subPage ) { |
40 | $out->setStatusCode( 404 ); |
41 | $out->addHTML( |
42 | Html::errorBox( |
43 | $out->msg( 'mobile-frontend-generic-404-title' )->text(), |
44 | $out->msg( 'mobile-frontend-generic-404-desc' )->text() |
45 | ) |
46 | ); |
47 | |
48 | return; |
49 | } |
50 | $out->redirect( $this->getDesktopUrl( $subPage ), '301' ); |
51 | } |
52 | } |