Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 8
0.00% covered (danger)
0.00%
0 / 3
CRAP
0.00% covered (danger)
0.00%
0 / 1
SpecialShortUrl
0.00% covered (danger)
0.00%
0 / 8
0.00% covered (danger)
0.00%
0 / 3
20
0.00% covered (danger)
0.00%
0 / 1
 __construct
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 execute
0.00% covered (danger)
0.00%
0 / 6
0.00% covered (danger)
0.00%
0 / 1
6
 getGroupName
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2/**
3 * A special page that provides redirects to articles via their page IDs
4 *
5 * @file
6 * @ingroup Extensions
7 * @author Yuvi Panda, http://yuvi.in
8 * @copyright © 2011 Yuvaraj Pandian (yuvipanda@yuvi.in)
9 * @license BSD-3-Clause
10 */
11
12namespace MediaWiki\Extension\ShortUrl\Specials;
13
14use MediaWiki\Extension\ShortUrl\Utils;
15use MediaWiki\SpecialPage\UnlistedSpecialPage;
16
17/**
18 * Provides the actual redirection
19 *
20 * @ingroup SpecialPage
21 */
22class SpecialShortUrl extends UnlistedSpecialPage {
23
24    /**
25     * Constructor
26     */
27    public function __construct() {
28        parent::__construct( 'ShortUrl' );
29    }
30
31    /**
32     * Main execution function
33     *
34     * @param string|null $par Parameters passed to the page
35     */
36    public function execute( $par ) {
37        $out = $this->getOutput();
38
39        $title = Utils::decodeURL( $par );
40        if ( $title !== false ) {
41            $out->redirect( $title->getFullURL(), '301' );
42        } else {
43            $parEsc = wfEscapeWikiText( $par );
44            $out->showErrorPage( 'shorturl-not-found-title', 'shorturl-not-found-message', [ $parEsc ] );
45        }
46    }
47
48    /**
49     * @inheritDoc
50     */
51    protected function getGroupName() {
52        return 'pagetools';
53    }
54}