From: umherirrender Date: Thu, 2 Jan 2014 10:59:10 +0000 (+0100) Subject: Change Title::getInterwiki() in conditions to Title::isExternal() X-Git-Tag: 1.31.0-rc.0~17396^2~1 X-Git-Url: https://git.heureux-cyclage.org/?a=commitdiff_plain;h=65a4ae9fe949be90647af719962ec6092561e77a;p=lhc%2Fweb%2Fwiklou.git Change Title::getInterwiki() in conditions to Title::isExternal() Change-Id: Icce26e6194ae96f262029554e05b49117d5e112e --- diff --git a/includes/Export.php b/includes/Export.php index b4a507d2b4..639ba28943 100644 --- a/includes/Export.php +++ b/includes/Export.php @@ -866,7 +866,7 @@ class XmlDumpWriter { * @since 1.18 */ public static function canonicalTitle( Title $title ) { - if ( $title->getInterwiki() ) { + if ( $title->isExternal() ) { return $title->getPrefixedText(); } diff --git a/includes/Import.php b/includes/Import.php index 8b7af02a0f..721b94b5e3 100644 --- a/includes/Import.php +++ b/includes/Import.php @@ -1717,7 +1717,7 @@ class ImportStreamSource { return Status::newFatal( 'import-noarticle' ); } $link = Title::newFromText( "$interwiki:Special:Export/$page" ); - if ( is_null( $link ) || $link->getInterwiki() == '' ) { + if ( is_null( $link ) || !$link->isExternal() ) { return Status::newFatal( 'importbadinterwiki' ); } else { $params = array(); diff --git a/includes/Linker.php b/includes/Linker.php index 27f8ab4514..c4e26085b7 100644 --- a/includes/Linker.php +++ b/includes/Linker.php @@ -1446,7 +1446,7 @@ class Linker { $target = Title::newFromText( $linkTarget ); if ( $target ) { - if ( $target->getText() == '' && $target->getInterwiki() === '' + if ( $target->getText() == '' && !$target->isExternal() && !self::$commentLocal && self::$commentContextTitle ) { $newTarget = clone ( self::$commentContextTitle ); diff --git a/includes/PrefixSearch.php b/includes/PrefixSearch.php index 3c464c5821..780cae5308 100644 --- a/includes/PrefixSearch.php +++ b/includes/PrefixSearch.php @@ -44,7 +44,7 @@ class PrefixSearch { // Find a Title which is not an interwiki and is in NS_MAIN $title = Title::newFromText( $search ); - if ( $title && $title->getInterwiki() == '' ) { + if ( $title && !$title->isExternal() ) { $ns = array( $title->getNamespace() ); if ( $ns[0] == NS_MAIN ) { $ns = $namespaces; // no explicit prefix, use default namespaces @@ -57,7 +57,7 @@ class PrefixSearch { $title = Title::newFromText( $search . 'Dummy' ); if ( $title && $title->getText() == 'Dummy' && $title->getNamespace() != NS_MAIN - && $title->getInterwiki() == '' ) { + && !$title->isExternal() ) { return self::searchBackend( array( $title->getNamespace() ), '', $limit ); } diff --git a/includes/Title.php b/includes/Title.php index 5ab9e94d6d..0b4b99c800 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -685,7 +685,7 @@ class Title { * @return Bool TRUE if this is an in-project interwiki link or a wikilink, FALSE otherwise */ public function isLocal() { - if ( $this->mInterwiki != '' ) { + if ( $this->isExternal() ) { $iw = Interwiki::fetch( $this->mInterwiki ); if ( $iw ) { return $iw->isLocal(); @@ -719,7 +719,7 @@ class Title { * @return Bool TRUE if this is transcludable */ public function isTrans() { - if ( $this->mInterwiki == '' ) { + if ( !$this->isExternal() ) { return false; } @@ -732,7 +732,7 @@ class Title { * @return String the DB name */ public function getTransWikiID() { - if ( $this->mInterwiki == '' ) { + if ( !$this->isExternal() ) { return false; } @@ -830,7 +830,7 @@ class Title { public function getNsText() { global $wgContLang; - if ( $this->mInterwiki != '' ) { + if ( $this->isExternal() ) { // This probably shouldn't even happen. ohh man, oh yuck. // But for interwiki transclusion it sometimes does. // Shit. Shit shit shit. @@ -1014,7 +1014,7 @@ class Title { * @return Bool TRUE or FALSE */ public function isMovable() { - if ( !MWNamespace::isMovable( $this->getNamespace() ) || $this->getInterwiki() != '' ) { + if ( !MWNamespace::isMovable( $this->getNamespace() ) || $this->isExternal() ) { // Interwiki title or immovable namespace. Hooks don't get to override here return false; } @@ -1236,7 +1236,7 @@ class Title { */ private function prefix( $name ) { $p = ''; - if ( $this->mInterwiki != '' ) { + if ( $this->isExternal() ) { $p = $this->mInterwiki . ':'; } @@ -1735,7 +1735,7 @@ class Title { * interwiki link */ public function getEditURL() { - if ( $this->mInterwiki != '' ) { + if ( $this->isExternal() ) { return ''; } $s = $this->getLocalURL( 'action=edit' ); @@ -3250,7 +3250,7 @@ class Title { } while ( true ); # We already know that some pages won't be in the database! - if ( $this->mInterwiki != '' || NS_SPECIAL == $this->mNamespace ) { + if ( $this->isExternal() || NS_SPECIAL == $this->mNamespace ) { $this->mArticleID = 0; } $fragment = strstr( $dbkey, '#' ); @@ -3306,13 +3306,13 @@ class Title { # and [[Foo]] point to the same place. Don't force it for interwikis, since the # other site might be case-sensitive. $this->mUserCaseDBKey = $dbkey; - if ( $this->mInterwiki == '' ) { + if ( !$this->isExternal() ) { $dbkey = self::capitalize( $dbkey, $this->mNamespace ); } # Can't make a link to a namespace alone... "empty" local links can only be # self-links with a fragment identifier. - if ( $dbkey == '' && $this->mInterwiki == '' && $this->mNamespace != NS_MAIN ) { + if ( $dbkey == '' && !$this->isExternal() && $this->mNamespace != NS_MAIN ) { return false; } @@ -3582,7 +3582,7 @@ class Title { if ( !$this->isMovable() ) { $errors[] = array( 'immobile-source-namespace', $this->getNsText() ); } - if ( $nt->getInterwiki() != '' ) { + if ( $nt->isExternal() ) { $errors[] = array( 'immobile-target-namespace-iw' ); } if ( !$nt->isMovable() ) { @@ -4494,7 +4494,7 @@ class Title { return $isKnown; } - if ( $this->mInterwiki != '' ) { + if ( $this->isExternal() ) { return true; // any interwiki link might be viewable, for all we know } diff --git a/includes/Wiki.php b/includes/Wiki.php index 5ebf5a0798..1bb9c403b0 100644 --- a/includes/Wiki.php +++ b/includes/Wiki.php @@ -121,7 +121,7 @@ class MediaWiki { $ret = Title::newMainPage(); } - if ( $ret === null || ( $ret->getDBkey() == '' && $ret->getInterwiki() == '' ) ) { + if ( $ret === null || ( $ret->getDBkey() == '' && !$ret->isExternal() ) ) { $ret = SpecialPage::getTitleFor( 'Badtitle' ); } @@ -197,7 +197,7 @@ class MediaWiki { wfRunHooks( 'BeforeInitialize', array( &$title, &$unused, &$output, &$user, $request, $this ) ); // Invalid titles. Bug 21776: The interwikis must redirect even if the page name is empty. - if ( is_null( $title ) || ( $title->getDBkey() == '' && $title->getInterwiki() == '' ) + if ( is_null( $title ) || ( $title->getDBkey() == '' && !$title->isExternal() ) || $title->isSpecial( 'Badtitle' ) ) { $this->context->setTitle( SpecialPage::getTitleFor( 'Badtitle' ) ); @@ -231,7 +231,7 @@ class MediaWiki { $pageView = false; // was an article or special page viewed? // Interwiki redirects - if ( $title->getInterwiki() != '' ) { + if ( $title->isExternal() ) { $rdfrom = $request->getVal( 'rdfrom' ); if ( $rdfrom ) { $url = $title->getFullURL( array( 'rdfrom' => $rdfrom ) ); diff --git a/includes/api/ApiQueryBase.php b/includes/api/ApiQueryBase.php index d9aacaaf5d..32a03f13d0 100644 --- a/includes/api/ApiQueryBase.php +++ b/includes/api/ApiQueryBase.php @@ -493,7 +493,7 @@ abstract class ApiQueryBase extends ApiBase { if ( !$t ) { $this->dieUsageMsg( array( 'invalidtitle', $titlePart ) ); } - if ( $defaultNamespace != $t->getNamespace() || $t->getInterwiki() !== '' ) { + if ( $defaultNamespace != $t->getNamespace() || $t->isExternal() ) { // This can happen in two cases. First, if you call titlePartToKey with a title part // that looks like a namespace, but with $defaultNamespace = NS_MAIN. It would be very // difficult to handle such a case. Such cases cannot exist and are therefore treated diff --git a/includes/job/jobs/DoubleRedirectJob.php b/includes/job/jobs/DoubleRedirectJob.php index 99d7527486..94b56ef733 100644 --- a/includes/job/jobs/DoubleRedirectJob.php +++ b/includes/job/jobs/DoubleRedirectJob.php @@ -197,7 +197,7 @@ class DoubleRedirectJob extends Job { } $seenTitles[$titleText] = true; - if ( $title->getInterwiki() ) { + if ( $title->isExternal() ) { // If the target is interwiki, we have to break early (bug 40352). // Otherwise it will look up a row in the local page table // with the namespace/page of the interwiki target which can cause diff --git a/includes/parser/ParserOutput.php b/includes/parser/ParserOutput.php index 76d14cf64d..8cd978b14d 100644 --- a/includes/parser/ParserOutput.php +++ b/includes/parser/ParserOutput.php @@ -279,10 +279,10 @@ class ParserOutput extends CacheTime { * @throws MWException if given invalid input */ function addInterwikiLink( $title ) { - $prefix = $title->getInterwiki(); - if ( $prefix == '' ) { + if ( !$title->isExternal() ) { throw new MWException( 'Non-interwiki link passed, internal parser error.' ); } + $prefix = $title->getInterwiki(); if ( !isset( $this->mInterwikiLinks[$prefix] ) ) { $this->mInterwikiLinks[$prefix] = array(); } diff --git a/includes/specials/SpecialExport.php b/includes/specials/SpecialExport.php index bbed9e6086..6fb5e8c1b0 100644 --- a/includes/specials/SpecialExport.php +++ b/includes/specials/SpecialExport.php @@ -315,7 +315,7 @@ class SpecialExport extends SpecialPage { foreach ( explode( "\n", $page ) as $pageName ) { $pageName = trim( $pageName ); $title = Title::newFromText( $pageName ); - if ( $title && $title->getInterwiki() == '' && $title->getText() !== '' ) { + if ( $title && !$title->isExternal() && $title->getText() !== '' ) { // Only record each page once! $pageSet[$title->getPrefixedText()] = true; } diff --git a/includes/specials/SpecialRecentchangeslinked.php b/includes/specials/SpecialRecentchangeslinked.php index 5dee226672..9a9cd1385e 100644 --- a/includes/specials/SpecialRecentchangeslinked.php +++ b/includes/specials/SpecialRecentchangeslinked.php @@ -65,7 +65,7 @@ class SpecialRecentChangesLinked extends SpecialRecentChanges { } $outputPage = $this->getOutput(); $title = Title::newFromURL( $target ); - if ( !$title || $title->getInterwiki() != '' ) { + if ( !$title || $title->isExternal() ) { $outputPage->addHtml( '
' . $this->msg( 'allpagesbadtitle' )->parse() . '
' ); return false; }