* @return bool
*/
public function isValid() {
- $ns = $this->getNamespace();
-
- if ( !MWNamespace::exists( $ns ) ) {
+ if ( !MWNamespace::exists( $this->mNamespace ) ) {
return false;
}
try {
$parser = MediaWikiServices::getInstance()->getTitleParser();
- $parser->parseTitle( $this->getDBkey(), $ns );
+ $parser->parseTitle( $this->mDbkeyform, $this->mNamespace );
return true;
} catch ( MalformedTitleException $ex ) {
return false;
if ( $this->mTitleValue === null ) {
try {
$this->mTitleValue = new TitleValue(
- $this->getNamespace(),
- $this->getDBkey(),
- $this->getFragment(),
- $this->getInterwiki()
+ $this->mNamespace,
+ $this->mDbkeyform,
+ $this->mFragment,
+ $this->mInterwiki
);
} catch ( InvalidArgumentException $ex ) {
wfDebug( __METHOD__ . ': Can\'t create a TitleValue for [[' .
* @return bool
*/
public function isWatchable() {
- return !$this->isExternal() && MWNamespace::isWatchable( $this->getNamespace() );
+ return !$this->isExternal() && MWNamespace::isWatchable( $this->mNamespace );
}
/**
* @return bool
*/
public function isSpecialPage() {
- return $this->getNamespace() == NS_SPECIAL;
+ return $this->mNamespace == NS_SPECIAL;
}
/**
*/
public function isSpecial( $name ) {
if ( $this->isSpecialPage() ) {
- list( $thisName, /* $subpage */ ) = SpecialPageFactory::resolveAlias( $this->getDBkey() );
+ list( $thisName, /* $subpage */ ) = SpecialPageFactory::resolveAlias( $this->mDbkeyform );
if ( $name == $thisName ) {
return true;
}
* @since 1.19
*/
public function inNamespace( $ns ) {
- return MWNamespace::equals( $this->getNamespace(), $ns );
+ return MWNamespace::equals( $this->mNamespace, $ns );
}
/**
* @return bool
*/
public function hasSubjectNamespace( $ns ) {
- return MWNamespace::subjectEquals( $this->getNamespace(), $ns );
+ return MWNamespace::subjectEquals( $this->mNamespace, $ns );
}
/**
* @return bool
*/
public function isContentPage() {
- return MWNamespace::isContent( $this->getNamespace() );
+ return MWNamespace::isContent( $this->mNamespace );
}
/**
* @return bool
*/
public function isMovable() {
- if ( !MWNamespace::isMovable( $this->getNamespace() ) || $this->isExternal() ) {
+ if ( !MWNamespace::isMovable( $this->mNamespace ) || $this->isExternal() ) {
// Interwiki title or immovable namespace. Hooks don't get to override here
return false;
}
public function isConversionTable() {
// @todo ConversionTable should become a separate content model.
- return $this->getNamespace() == NS_MEDIAWIKI &&
+ return $this->mNamespace == NS_MEDIAWIKI &&
strpos( $this->getText(), 'Conversiontable/' ) === 0;
}
$this->hasContentModel( CONTENT_MODEL_CSS )
// paranoia - a MediaWiki: namespace page with mismatching extension and content
// model is probably by mistake and might get handled incorrectly (see e.g. T112937)
- || substr( $this->getDBkey(), -4 ) === '.css'
+ || substr( $this->mDbkeyform, -4 ) === '.css'
)
);
}
$this->hasContentModel( CONTENT_MODEL_JSON )
// paranoia - a MediaWiki: namespace page with mismatching extension and content
// model is probably by mistake and might get handled incorrectly (see e.g. T112937)
- || substr( $this->getDBkey(), -5 ) === '.json'
+ || substr( $this->mDbkeyform, -5 ) === '.json'
)
);
}
$this->hasContentModel( CONTENT_MODEL_JAVASCRIPT )
// paranoia - a MediaWiki: namespace page with mismatching extension and content
// model is probably by mistake and might get handled incorrectly (see e.g. T112937)
- || substr( $this->getDBkey(), -3 ) === '.js'
+ || substr( $this->mDbkeyform, -3 ) === '.js'
)
);
}
* @return bool
*/
public function isTalkPage() {
- return MWNamespace::isTalk( $this->getNamespace() );
+ return MWNamespace::isTalk( $this->mNamespace );
}
/**
* @return Title The object for the talk page
*/
public function getTalkPage() {
- return self::makeTitle( MWNamespace::getTalk( $this->getNamespace() ), $this->getDBkey() );
+ return self::makeTitle( MWNamespace::getTalk( $this->mNamespace ), $this->mDbkeyform );
}
/**
*/
public function getSubjectPage() {
// Is this the same title?
- $subjectNS = MWNamespace::getSubject( $this->getNamespace() );
- if ( $this->getNamespace() == $subjectNS ) {
+ $subjectNS = MWNamespace::getSubject( $this->mNamespace );
+ if ( $this->mNamespace == $subjectNS ) {
return $this;
}
- return self::makeTitle( $subjectNS, $this->getDBkey() );
+ return self::makeTitle( $subjectNS, $this->mDbkeyform );
}
/**
} elseif ( $this->isExternal()
&& !self::getInterwikiLookup()->fetch( $this->mInterwiki )->isLocal()
) {
- return '#' . Sanitizer::escapeIdForExternalInterwiki( $this->getFragment() );
+ return '#' . Sanitizer::escapeIdForExternalInterwiki( $this->mFragment );
}
- return '#' . Sanitizer::escapeIdForLink( $this->getFragment() );
+ return '#' . Sanitizer::escapeIdForLink( $this->mFragment );
}
/**
*/
public function createFragmentTarget( $fragment ) {
return self::makeTitle(
- $this->getNamespace(),
+ $this->mNamespace,
$this->getText(),
$fragment,
- $this->getInterwiki()
+ $this->mInterwiki
);
}
public function getFullText() {
$text = $this->getPrefixedText();
if ( $this->hasFragment() ) {
- $text .= '#' . $this->getFragment();
+ $text .= '#' . $this->mFragment;
}
return $text;
}
* @since 1.20
*/
public function getRootTitle() {
- return self::makeTitle( $this->getNamespace(), $this->getRootText() );
+ return self::makeTitle( $this->mNamespace, $this->getRootText() );
}
/**
* @since 1.20
*/
public function getBaseTitle() {
- return self::makeTitle( $this->getNamespace(), $this->getBaseText() );
+ return self::makeTitle( $this->mNamespace, $this->getBaseText() );
}
/**
* @since 1.20
*/
public function getSubpage( $text ) {
- return self::makeTitleSafe( $this->getNamespace(), $this->getText() . '/' . $text );
+ return self::makeTitleSafe( $this->mNamespace, $this->getText() . '/' . $text );
}
/**
# Yes! It can in interwiki transclusion. But... it probably shouldn't.
$namespace .= ':';
}
- $url = $interwiki->getURL( $namespace . $this->getDBkey() );
+ $url = $interwiki->getURL( $namespace . $this->mDbkeyform );
$url = wfAppendQuery( $url, $query );
} else {
$dbkey = wfUrlencode( $this->getPrefixedDBkey() );
// Check for explicit whitelisting with and without underscores
if ( in_array( $name, $wgWhitelistRead, true ) || in_array( $dbName, $wgWhitelistRead, true ) ) {
$whitelisted = true;
- } elseif ( $this->getNamespace() == NS_MAIN ) {
+ } elseif ( $this->mNamespace == NS_MAIN ) {
# Old settings might have the title prefixed with
# a colon for main-namespace pages
if ( in_array( ':' . $name, $wgWhitelistRead ) ) {
}
} elseif ( $this->isSpecialPage() ) {
# If it's a special page, ditch the subpage bit and check again
- $name = $this->getDBkey();
+ $name = $this->mDbkeyform;
list( $name, /* $subpage */ ) = SpecialPageFactory::resolveAlias( $name );
if ( $name ) {
$pure = SpecialPage::getTitleFor( $name )->getPrefixedText();
$types = self::getFilteredRestrictionTypes( $this->exists() );
- if ( $this->getNamespace() != NS_FILE ) {
+ if ( $this->mNamespace != NS_FILE ) {
# Remove the upload restriction for non-file titles
$types = array_diff( $types, [ 'upload' ] );
}
*/
protected function getTitleProtectionInternal() {
// Can't protect pages in special namespaces
- if ( $this->getNamespace() < 0 ) {
+ if ( $this->mNamespace < 0 ) {
return false;
}
'expiry' => 'pt_expiry',
'permission' => 'pt_create_perm'
] + $commentQuery['fields'],
- [ 'pt_namespace' => $this->getNamespace(), 'pt_title' => $this->getDBkey() ],
+ [ 'pt_namespace' => $this->mNamespace, 'pt_title' => $this->mDbkeyform ],
__METHOD__,
[],
$commentQuery['joins']
$dbw->delete(
'protected_titles',
- [ 'pt_namespace' => $this->getNamespace(), 'pt_title' => $this->getDBkey() ],
+ [ 'pt_namespace' => $this->mNamespace, 'pt_title' => $this->mDbkeyform ],
__METHOD__
);
$this->mTitleProtection = false;
$dbr = wfGetDB( DB_REPLICA );
- if ( $this->getNamespace() == NS_FILE ) {
+ if ( $this->mNamespace == NS_FILE ) {
$tables = [ 'imagelinks', 'page_restrictions' ];
$where_clauses = [
- 'il_to' => $this->getDBkey(),
+ 'il_to' => $this->mDbkeyform,
'il_from=pr_page',
'pr_cascade' => 1
];
} else {
$tables = [ 'templatelinks', 'page_restrictions' ];
$where_clauses = [
- 'tl_namespace' => $this->getNamespace(),
- 'tl_title' => $this->getDBkey(),
+ 'tl_namespace' => $this->mNamespace,
+ 'tl_title' => $this->mDbkeyform,
'tl_from=pr_page',
'pr_cascade' => 1
];
* doesn't allow subpages
*/
public function getSubpages( $limit = -1 ) {
- if ( !MWNamespace::hasSubpages( $this->getNamespace() ) ) {
+ if ( !MWNamespace::hasSubpages( $this->mNamespace ) ) {
return [];
}
$dbr = wfGetDB( DB_REPLICA );
- $conds['page_namespace'] = $this->getNamespace();
- $conds[] = 'page_title ' . $dbr->buildLike( $this->getDBkey() . '/', $dbr->anyString() );
+ $conds['page_namespace'] = $this->mNamespace;
+ $conds[] = 'page_title ' . $dbr->buildLike( $this->mDbkeyform . '/', $dbr->anyString() );
$options = [];
if ( $limit > -1 ) {
$options['LIMIT'] = $limit;
* @return int The number of archived revisions
*/
public function isDeleted() {
- if ( $this->getNamespace() < 0 ) {
+ if ( $this->mNamespace < 0 ) {
$n = 0;
} else {
$dbr = wfGetDB( DB_REPLICA );
$n = $dbr->selectField( 'archive', 'COUNT(*)',
- [ 'ar_namespace' => $this->getNamespace(), 'ar_title' => $this->getDBkey() ],
+ [ 'ar_namespace' => $this->mNamespace, 'ar_title' => $this->mDbkeyform ],
__METHOD__
);
- if ( $this->getNamespace() == NS_FILE ) {
+ if ( $this->mNamespace == NS_FILE ) {
$n += $dbr->selectField( 'filearchive', 'COUNT(*)',
- [ 'fa_name' => $this->getDBkey() ],
+ [ 'fa_name' => $this->mDbkeyform ],
__METHOD__
);
}
* @return bool
*/
public function isDeletedQuick() {
- if ( $this->getNamespace() < 0 ) {
+ if ( $this->mNamespace < 0 ) {
return false;
}
$dbr = wfGetDB( DB_REPLICA );
$deleted = (bool)$dbr->selectField( 'archive', '1',
- [ 'ar_namespace' => $this->getNamespace(), 'ar_title' => $this->getDBkey() ],
+ [ 'ar_namespace' => $this->mNamespace, 'ar_title' => $this->mDbkeyform ],
__METHOD__
);
- if ( !$deleted && $this->getNamespace() == NS_FILE ) {
+ if ( !$deleted && $this->mNamespace == NS_FILE ) {
$deleted = (bool)$dbr->selectField( 'filearchive', '1',
- [ 'fa_name' => $this->getDBkey() ],
+ [ 'fa_name' => $this->mDbkeyform ],
__METHOD__
);
}
* @return int The ID
*/
public function getArticleID( $flags = 0 ) {
- if ( $this->getNamespace() < 0 ) {
+ if ( $this->mNamespace < 0 ) {
$this->mArticleID = 0;
return $this->mArticleID;
}
// splitTitleString method, but the only implementation (MediaWikiTitleCodec) does
$titleCodec = MediaWikiServices::getInstance()->getTitleParser();
// MalformedTitleException can be thrown here
- $parts = $titleCodec->splitTitleString( $this->mDbkeyform, $this->getDefaultNamespace() );
+ $parts = $titleCodec->splitTitleString( $this->mDbkeyform, $this->mDefaultNamespace );
# Fill fields
$this->setFragment( '#' . $parts['fragment'] );
self::getSelectFields(),
[
"{$prefix}_from=page_id",
- "{$prefix}_namespace" => $this->getNamespace(),
- "{$prefix}_title" => $this->getDBkey() ],
+ "{$prefix}_namespace" => $this->mNamespace,
+ "{$prefix}_title" => $this->mDbkeyform ],
__METHOD__,
$options
);
];
}
// Do the source and target namespaces support subpages?
- if ( !MWNamespace::hasSubpages( $this->getNamespace() ) ) {
+ if ( !MWNamespace::hasSubpages( $this->mNamespace ) ) {
return [
- [ 'namespace-nosubpages', MWNamespace::getCanonicalName( $this->getNamespace() ) ],
+ [ 'namespace-nosubpages', MWNamespace::getCanonicalName( $this->mNamespace ) ],
];
}
if ( !MWNamespace::hasSubpages( $nt->getNamespace() ) ) {
continue;
}
$newPageName = preg_replace(
- '#^' . preg_quote( $this->getDBkey(), '#' ) . '#',
+ '#^' . preg_quote( $this->mDbkeyform, '#' ) . '#',
StringUtils::escapeRegexReplacement( $nt->getDBkey() ), # T23234
$oldSubpage->getDBkey() );
if ( $oldSubpage->isTalkPage() ) {
# Does the article have a history?
$row = $dbw->selectField( [ 'page', 'revision' ],
'rev_id',
- [ 'page_namespace' => $this->getNamespace(),
- 'page_title' => $this->getDBkey(),
+ [ 'page_namespace' => $this->mNamespace,
+ 'page_title' => $this->mDbkeyform,
'page_id=rev_page',
'page_latest != rev_id'
],
*/
public function equals( Title $title ) {
// Note: === is necessary for proper matching of number-like titles.
- return $this->getInterwiki() === $title->getInterwiki()
- && $this->getNamespace() == $title->getNamespace()
- && $this->getDBkey() === $title->getDBkey();
+ return $this->mInterwiki === $title->mInterwiki
+ && $this->mNamespace == $title->mNamespace
+ && $this->mDbkeyform === $title->mDbkeyform;
}
/**
* @return bool
*/
public function isSubpageOf( Title $title ) {
- return $this->getInterwiki() === $title->getInterwiki()
- && $this->getNamespace() == $title->getNamespace()
- && strpos( $this->getDBkey(), $title->getDBkey() . '/' ) === 0;
+ return $this->mInterwiki === $title->mInterwiki
+ && $this->mNamespace == $title->mNamespace
+ && strpos( $this->mDbkeyform, $title->mDbkeyform . '/' ) === 0;
}
/**
return (bool)wfFindFile( $this );
case NS_SPECIAL:
// valid special page
- return SpecialPageFactory::exists( $this->getDBkey() );
+ return SpecialPageFactory::exists( $this->mDbkeyform );
case NS_MAIN:
// selflink, possibly with fragment
return $this->mDbkeyform == '';
* @return string|bool
*/
public function getDefaultMessageText() {
- if ( $this->getNamespace() != NS_MEDIAWIKI ) { // Just in case
+ if ( $this->mNamespace != NS_MEDIAWIKI ) { // Just in case
return false;
}
*/
public function touchLinks() {
DeferredUpdates::addUpdate( new HTMLCacheUpdate( $this, 'pagelinks', 'page-touch' ) );
- if ( $this->getNamespace() == NS_CATEGORY ) {
+ if ( $this->mNamespace == NS_CATEGORY ) {
DeferredUpdates::addUpdate(
new HTMLCacheUpdate( $this, 'categorylinks', 'category-touch' )
);
*/
public function getNamespaceKey( $prepend = 'nstab-' ) {
// Gets the subject namespace of this title
- $subjectNS = MWNamespace::getSubject( $this->getNamespace() );
+ $subjectNS = MWNamespace::getSubject( $this->mNamespace );
// Prefer canonical namespace name for HTML IDs
$namespaceKey = MWNamespace::getCanonicalName( $subjectNS );
if ( $namespaceKey === false ) {
$dbr = wfGetDB( DB_REPLICA );
$where = [
- 'rd_namespace' => $this->getNamespace(),
- 'rd_title' => $this->getDBkey(),
+ 'rd_namespace' => $this->mNamespace,
+ 'rd_title' => $this->mDbkeyform,
'rd_from = page_id'
];
if ( $this->isExternal() ) {
- $where['rd_interwiki'] = $this->getInterwiki();
+ $where['rd_interwiki'] = $this->mInterwiki;
} else {
$where[] = 'rd_interwiki = ' . $dbr->addQuotes( '' ) . ' OR rd_interwiki IS NULL';
}
$notices = [];
// Optional notice for the entire namespace
- $editnotice_ns = 'editnotice-' . $this->getNamespace();
+ $editnotice_ns = 'editnotice-' . $this->mNamespace;
$msg = wfMessage( $editnotice_ns );
if ( $msg->exists() ) {
$html = $msg->parseAsBlock();
}
}
- if ( MWNamespace::hasSubpages( $this->getNamespace() ) ) {
+ if ( MWNamespace::hasSubpages( $this->mNamespace ) ) {
// Optional notice for page itself and any parent page
- $parts = explode( '/', $this->getDBkey() );
+ $parts = explode( '/', $this->mDbkeyform );
$editnotice_base = $editnotice_ns;
while ( count( $parts ) > 0 ) {
$editnotice_base .= '-' . array_shift( $parts );
}
} else {
// Even if there are no subpages in namespace, we still don't want "/" in MediaWiki message keys
- $editnoticeText = $editnotice_ns . '-' . strtr( $this->getDBkey(), '/', '-' );
+ $editnoticeText = $editnotice_ns . '-' . strtr( $this->mDbkeyform, '/', '-' );
$msg = wfMessage( $editnoticeText );
if ( $msg->exists() ) {
$html = $msg->parseAsBlock();