3 * Implements Special:GoToInterwiki
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
21 * @ingroup SpecialPage
25 * Landing page for non-local interwiki links.
27 * Meant to warn people that the site they're visiting
28 * is not the local wiki (In case of phishing tricks).
29 * Only meant to be used for things that directly
30 * redirect from url (e.g. Special:Search/google:foo )
31 * Not meant for general interwiki linking (e.g.
32 * [[google:foo]] should still directly link)
34 * @ingroup SpecialPage
36 class SpecialGoToInterwiki
extends UnlistedSpecialPage
{
37 public function __construct( $name = 'GoToInterwiki' ) {
38 parent
::__construct( $name );
41 public function execute( $par ) {
42 // Allow forcing an interstitial for local interwikis. This is used
43 // when a redirect page is reached via a special page which resolves
44 // to a user-dependent value (as defined by
45 // RedirectSpecialPage::personallyIdentifiableTarget). See the hack
46 // for avoiding T109724 in MediaWiki::performRequest (which also
47 // explains why we can't use a query parameter instead).
49 // HHVM dies when substr_compare is used on an empty string so ensure it's not.
50 $force = ( substr_compare( $par ?
: 'x', 'force/', 0, 6 ) === 0 );
52 $par = substr( $par, 6 );
56 $target = Title
::newFromText( $par );
57 // Disallow special pages as a precaution against
58 // possible redirect loops.
59 if ( !$target ||
$target->isSpecialPage() ) {
60 $this->getOutput()->setStatusCode( 404 );
61 $this->getOutput()->addWikiMsg( 'gotointerwiki-invalid' );
65 $url = $target->getFullURL();
66 if ( !$target->isExternal() ||
( $target->isLocal() && !$force ) ) {
67 // Either a normal page, or a local interwiki.
69 $this->getOutput()->redirect( $url, '301' );
71 $this->getOutput()->addWikiMsg(
72 'gotointerwiki-external',
74 $target->getFullText()
82 public function requiresWrite() {
89 protected function getGroupName() {