Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
11 / 11 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| SpecialMobileDiff | |
100.00% |
11 / 11 |
|
100.00% |
2 / 2 |
5 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getRedirect | |
100.00% |
10 / 10 |
|
100.00% |
1 / 1 |
4 | |||
| 1 | <?php |
| 2 | |
| 3 | use MediaWiki\SpecialPage\RedirectSpecialPage; |
| 4 | use MediaWiki\SpecialPage\SpecialPage; |
| 5 | use MediaWiki\Title\Title; |
| 6 | |
| 7 | /** |
| 8 | * Formerly a special page to show the difference between two revisions of a page - decomissioned in T358293 |
| 9 | * Now redirects to the core diff functionality; or, if called without a subpage, to the form at Special:Diff |
| 10 | */ |
| 11 | class SpecialMobileDiff extends RedirectSpecialPage { |
| 12 | public function __construct() { |
| 13 | parent::__construct( 'MobileDiff' ); |
| 14 | } |
| 15 | |
| 16 | /** |
| 17 | * Determine the page to redirect to |
| 18 | * |
| 19 | * @param string|null $subPage The subpage, if any, passed to Special:MobileDiff |
| 20 | * @return Title|bool Either a Title object representing Special:Diff, or `true` to indicate that the redirect |
| 21 | * should be to index.php with the added parameters |
| 22 | */ |
| 23 | public function getRedirect( $subPage ) { |
| 24 | // If called without a subpage, redirect to the form at Special:Diff |
| 25 | if ( $subPage == null ) { |
| 26 | return SpecialPage::getTitleFor( 'Diff' ); |
| 27 | } |
| 28 | |
| 29 | // Retrieve the diff parameters from the subpage |
| 30 | $parts = explode( '...', $subPage ); |
| 31 | if ( count( $parts ) > 1 ) { |
| 32 | $this->mAddedRedirectParams['oldid'] = $parts[0]; |
| 33 | $this->mAddedRedirectParams['diff'] = $parts[1]; |
| 34 | } else { |
| 35 | $this->mAddedRedirectParams['diff'] = $parts[0]; |
| 36 | } |
| 37 | |
| 38 | // Maintain backwards compatibility: SpecialMobileDiff used |
| 39 | // `getRequest()->getBool( 'unhide' )`, whereas Article::showDiffPage |
| 40 | // currently uses `$request->getInt( 'unhide' ) === 1` |
| 41 | if ( $this->getRequest()->getBool( 'unhide' ) ) { |
| 42 | $this->mAddedRedirectParams['unhide'] = 1; |
| 43 | } |
| 44 | |
| 45 | // Redirect to index.php with the added query parameters |
| 46 | return true; |
| 47 | } |
| 48 | } |