Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 28 |
|
0.00% |
0 / 7 |
CRAP | |
0.00% |
0 / 1 |
| SpecialPermanentLink | |
0.00% |
0 / 27 |
|
0.00% |
0 / 7 |
90 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| getRedirect | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
6 | |||
| showNoRedirectPage | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
2 | |||
| showForm | |
0.00% |
0 / 10 |
|
0.00% |
0 / 1 |
2 | |||
| onFormSubmit | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
6 | |||
| isListed | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getGroupName | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * @license GPL-2.0-or-later |
| 4 | * @file |
| 5 | */ |
| 6 | |
| 7 | namespace MediaWiki\Specials; |
| 8 | |
| 9 | use MediaWiki\HTMLForm\HTMLForm; |
| 10 | use MediaWiki\SpecialPage\RedirectSpecialPage; |
| 11 | use MediaWiki\Title\Title; |
| 12 | |
| 13 | /** |
| 14 | * Redirect from Special:PermanentLink/### to index.php?oldid=###. |
| 15 | * |
| 16 | * @ingroup SpecialPage |
| 17 | */ |
| 18 | class SpecialPermanentLink extends RedirectSpecialPage { |
| 19 | public function __construct() { |
| 20 | parent::__construct( 'PermanentLink' ); |
| 21 | $this->mAllowedRedirectParams = []; |
| 22 | } |
| 23 | |
| 24 | /** |
| 25 | * @param string|null $subpage |
| 26 | * @return Title|bool |
| 27 | */ |
| 28 | public function getRedirect( $subpage ) { |
| 29 | $subpage = intval( $subpage ); |
| 30 | if ( $subpage === 0 ) { |
| 31 | return false; |
| 32 | } |
| 33 | $this->mAddedRedirectParams['oldid'] = $subpage; |
| 34 | |
| 35 | return true; |
| 36 | } |
| 37 | |
| 38 | protected function showNoRedirectPage() { |
| 39 | $this->addHelpLink( 'Help:PermanentLink' ); |
| 40 | $this->setHeaders(); |
| 41 | $this->outputHeader(); |
| 42 | $this->showForm(); |
| 43 | } |
| 44 | |
| 45 | private function showForm() { |
| 46 | HTMLForm::factory( 'ooui', [ |
| 47 | 'revid' => [ |
| 48 | 'type' => 'int', |
| 49 | 'name' => 'revid', |
| 50 | 'label-message' => 'permanentlink-revid', |
| 51 | ], |
| 52 | ], $this->getContext(), 'permanentlink' ) |
| 53 | ->setSubmitTextMsg( 'permanentlink-submit' ) |
| 54 | ->setSubmitCallback( $this->onFormSubmit( ... ) ) |
| 55 | ->show(); |
| 56 | } |
| 57 | |
| 58 | /** |
| 59 | * @param array $formData |
| 60 | */ |
| 61 | private function onFormSubmit( $formData ) { |
| 62 | $revid = $formData['revid']; |
| 63 | $title = $this->getPageTitle( $revid ?: null ); |
| 64 | $url = $title->getFullUrlForRedirect(); |
| 65 | $this->getOutput()->redirect( $url ); |
| 66 | } |
| 67 | |
| 68 | /** @inheritDoc */ |
| 69 | public function isListed() { |
| 70 | return true; |
| 71 | } |
| 72 | |
| 73 | /** @inheritDoc */ |
| 74 | protected function getGroupName() { |
| 75 | return 'redirects'; |
| 76 | } |
| 77 | } |
| 78 | |
| 79 | /** |
| 80 | * Retain the old class name for backwards compatibility. |
| 81 | * @deprecated since 1.41 |
| 82 | */ |
| 83 | class_alias( SpecialPermanentLink::class, 'SpecialPermanentLink' ); |