MediaWiki REL1_40
MediaWiki\Title\Title Class Reference

Represents a title within MediaWiki. More...

Inherits MediaWiki\Linker\LinkTarget, MediaWiki\Page\PageIdentity, and IDBAccessObject.

Collaboration diagram for MediaWiki\Title\Title:

Public Member Functions

 __clone ()
 
 __sleep ()
 
 __toString ()
 Return a string representation of this title.
 
 __wakeup ()
 
 areCascadeProtectionSourcesLoaded ()
 Determines whether cascading protection sources have already been loaded from the database.
 
 areRestrictionsCascading ()
 Returns cascading restrictions for the current article.
 
 areRestrictionsLoaded ()
 Accessor for mRestrictionsLoaded.
 
 canExist ()
 Can this title represent a page in the wiki's database?
 
 canHaveTalkPage ()
 Can this title have a corresponding talk page?
 
 canUseNoindex ()
 Whether the magic words INDEX and NOINDEX function for this page.
 
 createFragmentTarget (string $fragment)
 Creates a new Title for a different fragment of the same page.
 
 deleteTitleProtection ()
 Remove any title protection due to page existing.
 
 equals (object $other)
 Compares with another Title.
 
 estimateRevisionCount ()
 Get the approximate revision count of this page.
 
 exists ( $flags=0)
 Check if page exists.
 
 fixSpecialName ()
 If the Title refers to a special page alias which is not the local default, resolve the alias, and localise the name as necessary.
 
 flushRestrictions ()
 Flush the protection cache in this object and force reload from the database.
 
 getAllRestrictions ()
 Accessor/initialisation for mRestrictions.
 
 getArticleID ( $flags=0)
 Get the article ID for this Title from the link cache, adding it if necessary.
 
 getBacklinkCache ()
 Get a backlink cache object.
 
 getBaseText ()
 Get the base page name without a namespace, i.e.
 
 getBaseTitle ()
 Get the base page name title, i.e.
 
 getBrokenLinksFrom ()
 Get an array of Title objects referring to non-existent articles linked from this page.
 
 getCanonicalURL ( $query='', $query2=false)
 Get the URL for a canonical link, for use in things like IRC and e-mail notifications.
 
 getCascadeProtectionSources ( $getPages=true)
 Cascading protection: Get the source of any cascading restrictions on this page.
 
 getCategorySortkey ( $prefix='')
 Returns the raw sort key to be used for categories, with the specified prefix.
 
 getCdnUrls ()
 Get a list of URLs to purge from the CDN cache when this page changes.
 
 getContentModel ( $flags=0)
 Get the page's content model id, see the CONTENT_MODEL_XXX constants.
 
 getDBkey ()
 Get the main part with underscores.
 
 getDefaultMessageText ()
 Get the default (plain) message contents for an page that overrides an interface message key.
 
 getDefaultSystemMessage ()
 Same as getDefaultMessageText, but returns a Message object.
 
 getDeletedEditsCount ()
 Is there a version of this page in the deletion archive?
 
 getEditNotices ( $oldid=0)
 Get a list of rendered edit notices for this page.
 
 getEditURL ()
 Get the edit URL for this Title.
 
 getFragment ()
 Get the Title fragment (i.e.
 
 getFragmentForURL ()
 Get the fragment in URL form, including the "#" character if there is one.
 
 getFullText ()
 Get the prefixed title with spaces, plus any fragment (part beginning with '#')
 
 getFullURL ( $query='', $query2=false, $proto=PROTO_RELATIVE)
 Get a real URL referring to this title, with interwiki link and fragment.
 
 getFullUrlForRedirect ( $query='', $proto=PROTO_CURRENT)
 Get a url appropriate for making redirects based on an untrusted url arg.
 
 getId ( $wikiId=self::LOCAL)
 Returns the page ID.
 
 getInternalURL ( $query='', $query2=false)
 Get the URL form for an internal link.
 
 getInterwiki ()
 Get the interwiki prefix.
 
 getLatestRevID ( $flags=0)
 What is the page_latest field for this page?
 
 getLength ( $flags=0)
 What is the length of this page? Uses link cache, adding it if necessary.
 
 getLinksFrom ( $options=[], $table='pagelinks', $prefix='pl')
 Get an array of Title objects linked from this Title Also stores the IDs in the link cache.
 
 getLinksTo ( $options=[], $table='pagelinks', $prefix='pl')
 Get an array of Title objects linking to this Title Also stores the IDs in the link cache.
 
 getLinkURL ( $query='', $query2=false, $proto=false)
 Get a URL that's the simplest URL that will be valid to link, locally, to the current Title.
 
 getLocalURL ( $query='', $query2=false)
 Get a URL with no fragment or server name (relative URL) from a Title object.
 
 getNamespace ()
 Get the namespace index, i.e.
 
 getNamespaceKey ( $prepend='nstab-')
 Generate strings used for xml 'id' names in monobook tabs.
 
 getNsText ()
 Get the namespace text.
 
 getOtherPage ()
 Get the other title for this page, if this is a subject page get the talk page, if it is a subject page get the talk page.
 
 getPageLanguage ()
 Get the language in which the content of this page is written in wikitext.
 
 getPageViewLanguage ()
 Get the language in which the content of this page is written when viewed by user.
 
 getParentCategories ()
 Get categories to which this Title belongs and return an array of categories' names.
 
 getParentCategoryTree ( $children=[])
 Get a tree of parent categories.
 
 getPartialURL ()
 Get the URL-encoded form of the main part.
 
 getPrefixedDBkey ()
 Get the prefixed database key form.
 
 getPrefixedText ()
 Get the prefixed title with spaces.
 
 getPrefixedURL ()
 Get a URL-encoded title (not an actual URL) including interwiki.
 
 getRedirectsHere ( $ns=null)
 Get all extant redirects to this Title.
 
 getRestrictionExpiry ( $action)
 Get the expiry time for the restriction against a given action.
 
 getRestrictions ( $action)
 Accessor/initialisation for mRestrictions.
 
 getRestrictionTypes ()
 Returns restriction types for the current Title.
 
 getRootText ()
 Get the root page name text without a namespace, i.e.
 
 getRootTitle ()
 Get the root page name title, i.e.
 
 getSkinFromConfigSubpage ()
 Trim down a .css, .json, or .js subpage title to get the corresponding skin name.
 
 getSubjectNsText ()
 Get the namespace text of the subject (rather than talk) page.
 
 getSubjectPage ()
 Get a title object associated with the subject page of this talk page.
 
 getSubpage ( $text)
 Get the title for a subpage of the current page.
 
 getSubpages ( $limit=-1)
 Get all subpages of this page.
 
 getSubpageText ()
 Get the lowest-level subpage name, i.e.
 
 getSubpageUrlForm ()
 Get a URL-encoded form of the subpage text.
 
 getTalkNsText ()
 Get the namespace text of the talk page.
 
 getTalkPage ()
 Get a Title object associated with the talk page of this article.
 
 getTalkPageIfDefined ()
 Get a Title object associated with the talk page of this article, if such a talk page can exist.
 
 getTemplateLinksFrom ( $options=[])
 Get an array of Title objects used on this Title as a template Also stores the IDs in the link cache.
 
 getTemplateLinksTo ( $options=[])
 Get an array of Title objects using this Title as a template Also stores the IDs in the link cache.
 
 getText ()
 Get the text form (spaces not underscores) of the main part.
 
 getTitleProtection ()
 Is this title subject to title protection? Title protection is the one applied against creation of such title.
 
 getTitleValue ()
 Get a TitleValue object representing this Title.
 
 getTouched ( $flags=self::READ_NORMAL)
 Get the last touched timestamp.
 
 getTransWikiID ()
 Returns the DB name of the distant wiki which owns the object.
 
 getWikiId ()
 Returns false to indicate that this Title belongs to the local wiki.
 
 hasContentModel ( $id)
 Convenience method for checking a title's content model name.
 
 hasDeletedEdits ()
 Is there a version of this page in the deletion archive?
 
 hasFragment ()
 Check if a Title fragment is set.
 
 hasSourceText ()
 Does this page have source text?
 
 hasSubjectNamespace ( $ns)
 Returns true if the title has the same subject namespace as the namespace specified.
 
 hasSubpages ()
 Does this have subpages? (Warning, usually requires an extra DB query.)
 
 inNamespace (int $ns)
 Returns true if the title is inside the specified namespace.
 
 inNamespaces (... $namespaces)
 Returns true if the title is inside one of the specified namespaces.
 
 invalidateCache ( $purgeTime=null)
 Updates page_touched for this page; called from LinksUpdate.php.
 
 isAlwaysKnown ()
 Should links to this title be shown as potentially viewable (i.e.
 
 isBigDeletion ()
 Check whether the number of revisions of this page surpasses $wgDeleteRevisionsLimit.
 
 isCascadeProtected ()
 Cascading protection: Return true if cascading restrictions apply to this page, false if not.
 
 isContentPage ()
 Is this Title in a namespace which contains content? In other words, is this a content page, for the purposes of calculating statistics, etc?
 
 isConversionTable ()
 Is this a conversion table for the LanguageConverter?
 
 isDeleted ()
 Is there a version of this page in the deletion archive?
 
 isDeletedQuick ()
 Is there a version of this page in the deletion archive?
 
 isExternal ()
 Is this Title interwiki?
 
 isKnown ()
 Does this title refer to a page that can (or might) be meaningfully viewed? In particular, this function may be used to determine if links to the title should be rendered as "bluelinks" (as opposed to "redlinks" to non-existent pages).
 
 isLocal ()
 Determine whether the object refers to a page within this project (either this wiki or a wiki with a local interwiki, see https://www.mediawiki.org/wiki/Manual:Interwiki_table#iw_local )
 
 isMainPage ()
 Is this the mainpage?
 
 isMovable ()
 Would anybody with sufficient privileges be able to move this page? Some pages just aren't movable.
 
 isNewPage ( $flags=self::READ_NORMAL)
 Check if this is a new page.
 
 isProtected ( $action='')
 Does the title correspond to a protected article?
 
 isRawHtmlMessage ()
 Is this a message which can contain raw HTML?
 
 isRedirect ( $flags=0)
 Is this an article that is a redirect page? Uses link cache, adding it if necessary.
 
 isSameLinkAs (LinkTarget $other)
 
 isSamePageAs (PageReference $other)
 
 isSemiProtected ( $action='edit')
 Is this page "semi-protected" - the only protection levels are listed in $wgSemiprotectedRestrictionLevels?
 
 isSingleRevRedirect ()
 Locks the page row and check if this page is single revision redirect.
 
 isSiteConfigPage ()
 Could this MediaWiki namespace page contain custom CSS, JSON, or JavaScript for the global UI.
 
 isSiteCssConfigPage ()
 Is this a sitewide CSS "config" page?
 
 isSiteJsConfigPage ()
 Is this a sitewide JS "config" page?
 
 isSiteJsonConfigPage ()
 Is this a sitewide JSON "config" page?
 
 isSpecial ( $name)
 Returns true if this title resolves to the named special page.
 
 isSpecialPage ()
 Returns true if this is a special page.
 
 isSubpage ()
 Is this a subpage?
 
 isSubpageOf (Title $title)
 Check if this title is a subpage of another title.
 
 isTalkPage ()
 Is this a talk page of some sort?
 
 isTrans ()
 Determine whether the object refers to a page within this project and is transcludable.
 
 isUserConfigPage ()
 Is this a "config" (.css, .json, or .js) sub-page of a user page?
 
 isUserCssConfigPage ()
 Is this a CSS "config" sub-page of a user page?
 
 isUserJsConfigPage ()
 Is this a JS "config" sub-page of a user page?
 
 isUserJsonConfigPage ()
 Is this a JSON "config" sub-page of a user page?
 
 isValid ()
 Returns true if the title is a valid link target, and that it has been properly normalized.
 
 isValidRedirectTarget ()
 Check if this Title is a valid redirect target.
 
 isWikitextPage ()
 Does that page contain wikitext, or it is JS, CSS or whatever?
 
 loadFromRow ( $row)
 Load Title object fields from a DB row.
 
 loadRestrictions ( $flags=0)
 Load restrictions from the page_restrictions table.
 
 loadRestrictionsFromRows ( $rows)
 Compiles list of active page restrictions from both page table (pre 1.10) and page_restrictions table for this existing page.
 
 pageCond ()
 Get an associative array for selecting this title from the "page" table.
 
 purgeSquid ()
 Purge all applicable CDN URLs.
 
 resetArticleID ( $id)
 Inject a page ID, reset DB-loaded fields, and clear the link cache for this title.
 
 setContentModel ( $model)
 Set a proposed content model for the page for permissions checking.
 
 setFragment ( $fragment)
 Set the fragment for this title.
 
 toPageIdentity ()
 Returns the page represented by this Title as a ProperPageIdentity.
 
 toPageRecord ( $flags=0)
 Returns the page represented by this Title as a ProperPageRecord.
 
 touchLinks ()
 Update page_touched timestamps and send CDN purge messages for pages linking to this title.
 
 wasLocalInterwiki ()
 Was this a local interwiki link?
 
- Public Member Functions inherited from MediaWiki\Page\PageIdentity
 exists ()
 Checks if the page currently exists.
 
- Public Member Functions inherited from MediaWiki\DAO\WikiAwareEntity
 assertWiki ( $wikiId)
 Throws if $wikiId is different from the return value of getWikiId().
 

Static Public Member Functions

static capitalize ( $text, $ns=NS_MAIN)
 Capitalize a text string for a title if it belongs to a namespace that capitalizes.
 
static castFromLinkTarget ( $linkTarget)
 Same as newFromLinkTarget, but if passed null, returns null.
 
static castFromPageIdentity (?PageIdentity $pageIdentity)
 Return a Title for a given PageIdentity.
 
static castFromPageReference (?PageReference $pageReference)
 Return a Title for a given Reference.
 
static clearCaches ()
 
static compare ( $a, $b)
 Callback for usort() to do title sorts by (namespace, title)
 
static convertByteClassToUnicodeClass ( $byteClass)
 Utility method for converting a character sequence from bytes to Unicode.
 
static getFilteredRestrictionTypes ( $exists=true)
 Get a filtered list of all restriction types supported by this wiki.
 
static legalChars ()
 Get a regex character class describing the legal characters in a link.
 
static makeName ( $ns, $title, $fragment='', $interwiki='', $canonicalNamespace=false)
 Make a prefixed DB key from a DB key and a namespace index.
 
static makeTitle ( $ns, $title, $fragment='', $interwiki='')
 Create a new Title from a namespace index and a DB key.
 
static makeTitleSafe ( $ns, $title, $fragment='', $interwiki='')
 Create a new Title from a namespace index and a DB key.
 
static newFromDBkey ( $key)
 Create a new Title from a prefixed DB key.
 
static newFromID ( $id, $flags=0)
 Create a new Title from an article ID.
 
static newFromIDs ( $ids)
 Make an array of titles from an array of IDs.
 
static newFromLinkTarget (LinkTarget $linkTarget, $forceClone='')
 Returns a Title given a LinkTarget.
 
static newFromRow ( $row)
 Make a Title object from a DB row.
 
static newFromText ( $text, $defaultNamespace=NS_MAIN)
 Create a new Title from text, such as what one would find in a link.
 
static newFromTextThrow ( $text, $defaultNamespace=NS_MAIN)
 Like Title::newFromText(), but throws MalformedTitleException when the title is invalid, rather than returning null.
 
static newFromTitleValue (TitleValue $titleValue, $forceClone='')
 Returns a Title given a TitleValue.
 
static newFromURL ( $url)
 THIS IS NOT THE FUNCTION YOU WANT.
 
static newMainPage (MessageLocalizer $localizer=null)
 Create a new Title for the Main Page.
 
static purgeExpiredRestrictions ()
 Purge expired restrictions from the page_restrictions table.
 

Public Attributes

const GAID_FOR_UPDATE = 512
 Used to be GAID_FOR_UPDATE define().
 
const NEW_CLONE = 'clone'
 Flag for use with factory methods like newFromLinkTarget() that have a $forceClone parameter.
 
- Public Attributes inherited from IDBAccessObject
const READ_NONE = -1
 Constants for object loading bitfield flags (higher => higher QoS)
 

Static Protected Member Functions

static getSelectFields ()
 Returns a list of fields that are to be selected for initializing Title objects.
 

Private member variables

Please use the accessor functions instead.

Access: internal
int $mArticleID = -1
 Article ID, fetched from the link cache on demand.
 
string null $prefixedText = null
 Text form including namespace/interwiki, initialised on demand.
 
null bool $mRedirect = null
 Is the article at this title a redirect?
 
int false $mLatestID = false
 ID of most recent revision.
 
int $mLength = -1
 The page length, 0 for special pages.
 

Detailed Description

Represents a title within MediaWiki.

Optionally may contain an interwiki designation or namespace.

Note
This class can fetch various kinds of data from the database; however, it does so inefficiently.
Consider using a TitleValue object instead. TitleValue is more lightweight and does not rely on global state or the database.

Definition at line 82 of file Title.php.

Member Function Documentation

◆ __clone()

MediaWiki\Title\Title::__clone ( )

Definition at line 4199 of file Title.php.

◆ __sleep()

MediaWiki\Title\Title::__sleep ( )
Returns
array

Definition at line 4183 of file Title.php.

◆ __toString()

MediaWiki\Title\Title::__toString ( )

Return a string representation of this title.

Returns
string Representation of this title

Implements MediaWiki\Linker\LinkTarget.

Definition at line 1937 of file Title.php.

◆ __wakeup()

MediaWiki\Title\Title::__wakeup ( )

Definition at line 4193 of file Title.php.

References wfUrlencode().

◆ areCascadeProtectionSourcesLoaded()

MediaWiki\Title\Title::areCascadeProtectionSourcesLoaded ( )

Determines whether cascading protection sources have already been loaded from the database.

Deprecated
since 1.37, hard deprecated 1.40, use RestrictionStore::areCascadeProtectionSourcesLoaded instead
Returns
bool
Since
1.23

Definition at line 2549 of file Title.php.

References wfDeprecated().

◆ areRestrictionsCascading()

MediaWiki\Title\Title::areRestrictionsCascading ( )

Returns cascading restrictions for the current article.

Deprecated
since 1.37, hard deprecated 1.40, use RestrictionStore::areRestrictionsCascading instead
Returns
bool

Definition at line 2651 of file Title.php.

References wfDeprecated().

◆ areRestrictionsLoaded()

MediaWiki\Title\Title::areRestrictionsLoaded ( )

Accessor for mRestrictionsLoaded.

Deprecated
since 1.37, hard deprecated 1.40, use RestrictionStore::areRestrictionsLoaded instead
Returns
bool Whether or not the page's restrictions have already been loaded from the database
Since
1.23

Definition at line 2591 of file Title.php.

References wfDeprecated().

◆ canExist()

MediaWiki\Title\Title::canExist ( )

Can this title represent a page in the wiki's database?

Titles can exist as pages in the database if they are valid, and they are not Special pages, interwiki links, or fragment-only links.

See also
isValid()
Returns
bool true if and only if this title can be used to perform an edit.

Implements MediaWiki\Page\PageIdentity.

Definition at line 1265 of file Title.php.

Referenced by RequestContext\canUseWikiPage().

◆ canHaveTalkPage()

MediaWiki\Title\Title::canHaveTalkPage ( )

Can this title have a corresponding talk page?

False for relative section links (with getText() === ''), interwiki links (with getInterwiki() !== ''), and pages in NS_SPECIAL.

See also
NamespaceInfo::canHaveTalkPage
Since
1.30
Returns
bool True if this title either is a talk page or can have a talk page associated.

Definition at line 1251 of file Title.php.

◆ canUseNoindex()

MediaWiki\Title\Title::canUseNoindex ( )

Whether the magic words INDEX and NOINDEX function for this page.

Returns
bool

Definition at line 3896 of file Title.php.

References $wgExemptFromUserRobotsControl.

◆ capitalize()

static MediaWiki\Title\Title::capitalize ( $text,
$ns = NS_MAIN )
static

Capitalize a text string for a title if it belongs to a namespace that capitalizes.

Parameters
string$textContaining title to capitalize
int$nsNamespace index, defaults to NS_MAIN
Returns
string Containing capitalized title

Definition at line 2991 of file Title.php.

◆ castFromLinkTarget()

static MediaWiki\Title\Title::castFromLinkTarget ( $linkTarget)
static

Same as newFromLinkTarget, but if passed null, returns null.

Parameters
LinkTarget | null$linkTargetAssumed to be safe (if not null).
Returns
Title|null

Definition at line 339 of file Title.php.

◆ castFromPageIdentity()

static MediaWiki\Title\Title::castFromPageIdentity ( ?PageIdentity $pageIdentity)
static

Return a Title for a given PageIdentity.

If $pageIdentity is a Title, that Title is returned unchanged. If $pageIdentity is null, null is returned.

Since
1.36
Parameters
PageIdentity | null$pageIdentity
Returns
Title|null

Definition at line 352 of file Title.php.

◆ castFromPageReference()

static MediaWiki\Title\Title::castFromPageReference ( ?PageReference $pageReference)
static

Return a Title for a given Reference.

If $pageReference is a Title, that Title is returned unchanged. If $pageReference is null, null is returned.

Since
1.37
Parameters
PageReference | null$pageReference
Returns
Title|null

Definition at line 365 of file Title.php.

◆ clearCaches()

static MediaWiki\Title\Title::clearCaches ( )
static

Definition at line 2976 of file Title.php.

◆ compare()

static MediaWiki\Title\Title::compare ( $a,
$b )
static

Callback for usort() to do title sorts by (namespace, title)

Parameters
LinkTarget | PageReference$a
LinkTarget | PageReference$b
Returns
int Result of string comparison, or namespace comparison

Definition at line 914 of file Title.php.

◆ convertByteClassToUnicodeClass()

static MediaWiki\Title\Title::convertByteClassToUnicodeClass ( $byteClass)
static

Utility method for converting a character sequence from bytes to Unicode.

Primary usecase being converting $wgLegalTitleChars to a sequence usable in javascript, as PHP uses UTF-8 bytes where javascript uses Unicode code units.

Parameters
string$byteClass
Returns
string

Definition at line 781 of file Title.php.

◆ createFragmentTarget()

MediaWiki\Title\Title::createFragmentTarget ( string $fragment)

Creates a new Title for a different fragment of the same page.

Since
1.27
Parameters
string$fragment
Returns
Title

Implements MediaWiki\Linker\LinkTarget.

Definition at line 1856 of file Title.php.

Referenced by SpecialWhatLinksHere\listItem().

◆ deleteTitleProtection()

MediaWiki\Title\Title::deleteTitleProtection ( )

Remove any title protection due to page existing.

Deprecated
since 1.37, do not use (this is only for WikiPage::onArticleCreate)

Definition at line 2492 of file Title.php.

◆ equals()

MediaWiki\Title\Title::equals ( object $other)

Compares with another Title.

A Title object is considered equal to another Title if it has the same text, the same interwiki prefix, and the same namespace.

Note
This is different from isSameLinkAs(), which also compares the fragment part, and from isSamePageAs(), which takes into account the page ID.

@phpcs:disable MediaWiki.Commenting.FunctionComment.ObjectTypeHintParam

Parameters
object$other
Returns
bool true if $other is a Title and refers to the same page.

Definition at line 3450 of file Title.php.

Referenced by MediaWiki\Block\Restriction\PageRestriction\matches(), and MediaWiki\Storage\DerivedPageDataUpdater\prepareContent().

◆ estimateRevisionCount()

MediaWiki\Title\Title::estimateRevisionCount ( )

Get the approximate revision count of this page.

Returns
int

Definition at line 3422 of file Title.php.

References $dbr, DB_REPLICA, and wfGetDB().

◆ exists()

MediaWiki\Title\Title::exists ( $flags = 0)

Check if page exists.

For historical reasons, this function simply checks for the existence of the title in the page table, and will thus return false for interwiki links, special pages and the like. If you want to know if a title can be meaningfully viewed, you should probably call the isKnown() method instead.

Parameters
int$flagsEither a bitfield of class READ_* constants or GAID_FOR_UPDATE
Returns
bool

Definition at line 3523 of file Title.php.

Referenced by RedirectSpecialArticle\getRedirectQuery(), and SpecialUpload\getUploadForm().

◆ fixSpecialName()

MediaWiki\Title\Title::fixSpecialName ( )

If the Title refers to a special page alias which is not the local default, resolve the alias, and localise the name as necessary.

Otherwise, return $this

Returns
Title

Definition at line 1334 of file Title.php.

References NS_SPECIAL.

◆ flushRestrictions()

MediaWiki\Title\Title::flushRestrictions ( )

Flush the protection cache in this object and force reload from the database.

This is used when updating protection from WikiPage::doUpdateRestrictions().

Deprecated
since 1.37, now internal

Definition at line 2692 of file Title.php.

◆ getAllRestrictions()

MediaWiki\Title\Title::getAllRestrictions ( )

Accessor/initialisation for mRestrictions.

Deprecated
since 1.37, hard deprecated 1.40, use RestrictionStore::getAllRestrictions instead
Returns
array Keys are actions, values are arrays as returned by Title::getRestrictions()
Since
1.23

Definition at line 2623 of file Title.php.

References wfDeprecated().

◆ getArticleID()

MediaWiki\Title\Title::getArticleID ( $flags = 0)

Get the article ID for this Title from the link cache, adding it if necessary.

Parameters
int$flagsEither a bitfield of class READ_* constants or GAID_FOR_UPDATE
Returns
int The ID

Definition at line 2870 of file Title.php.

Referenced by MediaWiki\Block\Restriction\PageRestriction\newFromTitle().

◆ getBacklinkCache()

MediaWiki\Title\Title::getBacklinkCache ( )

Get a backlink cache object.

Deprecated
since 1.37, use BacklinkCacheFactory::getBacklinkCache()
Returns
BacklinkCache

Definition at line 3885 of file Title.php.

◆ getBaseText()

MediaWiki\Title\Title::getBaseText ( )

Get the base page name without a namespace, i.e.

the part before the subpage name

Note
the return value may contain trailing whitespace and is thus not safe for use with makeTitle or TitleValue.
Example:
Title::newFromText('User:Foo/Bar/Baz')->getBaseText();
# returns: 'Foo/Bar'
Returns
string Base name

Definition at line 2057 of file Title.php.

◆ getBaseTitle()

MediaWiki\Title\Title::getBaseTitle ( )

Get the base page name title, i.e.

the part before the subpage name.

Example:
Title::newFromText('User:Foo/Bar/Baz')->getBaseTitle();
# returns: Title{User:Foo/Bar}
Returns
Title
Since
1.20

Definition at line 2084 of file Title.php.

References $title.

◆ getBrokenLinksFrom()

MediaWiki\Title\Title::getBrokenLinksFrom ( )

Get an array of Title objects referring to non-existent articles linked from this page.

Todo
check if needed (used only in SpecialBrokenRedirects.php, and should use redirect table in this case).
Returns
Title[]

Definition at line 3207 of file Title.php.

References $dbr, $res, DB_REPLICA, and wfGetDB().

◆ getCanonicalURL()

MediaWiki\Title\Title::getCanonicalURL ( $query = '',
$query2 = false )

Get the URL for a canonical link, for use in things like IRC and e-mail notifications.

Uses $wgCanonicalServer and the GetCanonicalURL hook.

NOTE: Unlike getInternalURL(), the canonical URL includes the fragment

See also
self::getLocalURL for the arguments.
Parameters
string | array$query
string | false$query2Deprecated
Returns
string The URL
Since
1.18

Definition at line 2421 of file Title.php.

References PROTO_CANONICAL, and wfExpandUrl().

◆ getCascadeProtectionSources()

MediaWiki\Title\Title::getCascadeProtectionSources ( $getPages = true)

Cascading protection: Get the source of any cascading restrictions on this page.

Deprecated
since 1.37, hard deprecated 1.40, use RestrictionStore::getCascadeProtectionSources instead
Parameters
bool$getPagesWhether or not to retrieve the actual pages that the restrictions have come from and the actual restrictions themselves.
Returns
array Two elements: First is an array of Title objects of the pages from which cascading restrictions have come if $getPages is true, or a bool indicating whether any cascading protection applies if $getPages was set to false. Second is an array like that returned by Title::getAllRestrictions(), or an empty array if $getPages is false.

Definition at line 2570 of file Title.php.

References wfDeprecated().

◆ getCategorySortkey()

MediaWiki\Title\Title::getCategorySortkey ( $prefix = '')

Returns the raw sort key to be used for categories, with the specified prefix.

This will be fed to Collation::getSortKey() to get a binary sortkey that can be used for actual sorting.

Parameters
string$prefixThe prefix to be used, specified using {{defaultsort:}} or like [[Category:Foo|prefix]]. Empty for no prefix.
Returns
string

Definition at line 3915 of file Title.php.

◆ getCdnUrls()

MediaWiki\Title\Title::getCdnUrls ( )

Get a list of URLs to purge from the CDN cache when this page changes.

Deprecated
since 1.35 Use HtmlCacheUpdater
Returns
string[]

Definition at line 3243 of file Title.php.

◆ getContentModel()

MediaWiki\Title\Title::getContentModel ( $flags = 0)

Get the page's content model id, see the CONTENT_MODEL_XXX constants.

Todo
Deprecate this in favor of SlotRecord::getModel()
Parameters
int$flagsEither a bitfield of class READ_* constants or GAID_FOR_UPDATE
Returns
string Content model id

Definition at line 1121 of file Title.php.

Referenced by MediaWiki\EditPage\TextConflictHelper\__construct(), and SpecialWhatLinksHere\wlhLink().

◆ getDBkey()

MediaWiki\Title\Title::getDBkey ( )

Get the main part with underscores.

Returns
string Main part of the title, with underscores

Implements MediaWiki\Linker\LinkTarget.

Definition at line 1090 of file Title.php.

Referenced by ArchivedFile\__construct(), DoubleRedirectJob\fixRedirects(), UploadBase\getTitle(), and ForeignAPIFile\newFromTitle().

◆ getDefaultMessageText()

MediaWiki\Title\Title::getDefaultMessageText ( )

Get the default (plain) message contents for an page that overrides an interface message key.

Primary use cases:

  • Article:
    • Show default when viewing the page. The Article::getSubstituteContent method displays the default message content, instead of the 'noarticletext' placeholder message normally used.
  • EditPage:
    • Title of edit page. When creating an interface message override, the editor is told they are "Editing the page", instead of "Creating the page". (EditPage::setHeaders)
    • Edit notice. The 'translateinterface' edit notice is shown when creating or editing an interface message override. (EditPage::showIntro)
    • Opening the editor. The contents of the localisation message are used as contents of the editor when creating a new page in the MediaWiki namespace. This simplifies the process for editors when "changing" an interface message by creating an override. (EditPage::getContentObject)
    • Showing a diff. The left-hand side of a diff when an editor is previewing their changes before saving the creation of a page in the MediaWiki namespace. (EditPage::showDiff)
    • Disallowing a save. When attempting to create a MediaWiki-namespace page with the proposed content matching the interface message default, the save is rejected, the same way we disallow blank pages from being created. (EditPage::internalAttemptSave)
  • ApiEditPage:
    • Default content, when using the 'prepend' or 'append' feature.
  • SkinTemplate:
    • Label the create action as "Edit", if the page can be an override.
Returns
string|false

Definition at line 3667 of file Title.php.

◆ getDefaultSystemMessage()

MediaWiki\Title\Title::getDefaultSystemMessage ( )

Same as getDefaultMessageText, but returns a Message object.

See also
::getDefaultMessageText
Returns
?Message

Definition at line 3680 of file Title.php.

◆ getDeletedEditsCount()

MediaWiki\Title\Title::getDeletedEditsCount ( )

Is there a version of this page in the deletion archive?

Since
1.36
Returns
int The number of archived revisions

Definition at line 2809 of file Title.php.

References $dbr, DB_REPLICA, NS_FILE, and wfGetDB().

◆ getEditNotices()

MediaWiki\Title\Title::getEditNotices ( $oldid = 0)

Get a list of rendered edit notices for this page.

Array is keyed by the original message key, and values are rendered using parseAsBlock, so they will already be wrapped in paragraphs.

Since
1.21
Parameters
int$oldidRevision ID that's being edited
Returns
string[]

Definition at line 4073 of file Title.php.

References wfMessage().

◆ getEditURL()

MediaWiki\Title\Title::getEditURL ( )

Get the edit URL for this Title.

Returns
string The URL, or a null string if this is an interwiki link

Definition at line 2433 of file Title.php.

◆ getFilteredRestrictionTypes()

static MediaWiki\Title\Title::getFilteredRestrictionTypes ( $exists = true)
static

Get a filtered list of all restriction types supported by this wiki.

Deprecated
since 1.37, hard deprecated 1.40, use RestrictionStore::listAllRestrictionTypes instead
Parameters
bool$existsTrue to get all restriction types that apply to titles that do exist, False for all restriction types that apply to titles that do not exist
Returns
array

Definition at line 2452 of file Title.php.

References wfDeprecated().

◆ getFragment()

MediaWiki\Title\Title::getFragment ( )

Get the Title fragment (i.e.

\ the bit after the #) in text form

Use Title::hasFragment to check for a fragment

Returns
string Title fragment

Implements MediaWiki\Linker\LinkTarget.

Definition at line 1800 of file Title.php.

◆ getFragmentForURL()

MediaWiki\Title\Title::getFragmentForURL ( )

Get the fragment in URL form, including the "#" character if there is one.

Returns
string Fragment in URL form

Definition at line 1819 of file Title.php.

◆ getFullText()

MediaWiki\Title\Title::getFullText ( )

Get the prefixed title with spaces, plus any fragment (part beginning with '#')

Returns
string The prefixed title, with spaces and the fragment, including '#'

Definition at line 1947 of file Title.php.

Referenced by WikitextContentHandler\makeRedirectContent(), and WikitextContent\updateRedirect().

◆ getFullURL()

MediaWiki\Title\Title::getFullURL ( $query = '',
$query2 = false,
$proto = PROTO_RELATIVE )

Get a real URL referring to this title, with interwiki link and fragment.

See also
self::getLocalURL for the arguments.
wfExpandUrl
Parameters
string | array$query
string | string[] | false$query2
string | int | null$protoProtocol type to use in URL
Returns
string The URL

Definition at line 2213 of file Title.php.

References wfExpandUrl().

Referenced by CssContentHandler\makeRedirectContent(), and JavaScriptContentHandler\makeRedirectContent().

◆ getFullUrlForRedirect()

MediaWiki\Title\Title::getFullUrlForRedirect ( $query = '',
$proto = PROTO_CURRENT )

Get a url appropriate for making redirects based on an untrusted url arg.

This is basically the same as getFullUrl(), but in the case of external interwikis, we send the user to a landing page, to prevent possible phishing attacks and the like.

Note
Uses current protocol by default, since technically relative urls aren't allowed in redirects per HTTP spec, so this is not suitable for places where the url gets cached, as might pollute between https and non-https users.
See also
self::getLocalURL for the arguments.
Parameters
array | string$query
string$protoProtocol type to use in URL
Returns
string A url suitable to use in an HTTP location header.

Definition at line 2246 of file Title.php.

References SpecialPage\getTitleFor().

◆ getId()

MediaWiki\Title\Title::getId ( $wikiId = self::LOCAL)

Returns the page ID.

If this ID is 0, this means the page does not exist.

See also
getArticleID()
Since
1.36, since 1.35.6 as an alias of getArticleId()
Parameters
string | false$wikiIdThe wiki ID expected by the caller.
Exceptions
PreconditionExceptionif this Title instance does not represent a proper page, that is, if it is a section link, interwiki link, link to a special page, or such.
PreconditionExceptionif $wikiId is not false.
Returns
int

Implements MediaWiki\Page\PageIdentity.

Definition at line 4232 of file Title.php.

◆ getInternalURL()

MediaWiki\Title\Title::getInternalURL ( $query = '',
$query2 = false )

Get the URL form for an internal link.

  • Used in various CDN-related code, in case we have a different internal hostname for the server from the exposed one.

This uses $wgInternalServer to qualify the path, or $wgServer if $wgInternalServer is not set. If the server variable used is protocol-relative, the URL will be expanded to http://

See also
self::getLocalURL for the arguments.
Parameters
string | array$query
string | false$query2Deprecated
Returns
string The URL

Definition at line 2399 of file Title.php.

References $wgInternalServer, $wgServer, PROTO_HTTP, and wfExpandUrl().

◆ getInterwiki()

MediaWiki\Title\Title::getInterwiki ( )

Get the interwiki prefix.

Use Title::isExternal to check if a interwiki is set

Returns
string Interwiki prefix

Implements MediaWiki\Linker\LinkTarget.

Definition at line 1000 of file Title.php.

Referenced by WikitextContentHandler\makeRedirectContent().

◆ getLatestRevID()

MediaWiki\Title\Title::getLatestRevID ( $flags = 0)

What is the page_latest field for this page?

Parameters
int$flagsEither a bitfield of class READ_* constants or GAID_FOR_UPDATE
Returns
int Int or 0 if the page doesn't exist

Definition at line 2931 of file Title.php.

◆ getLength()

MediaWiki\Title\Title::getLength ( $flags = 0)

What is the length of this page? Uses link cache, adding it if necessary.

Parameters
int$flagsEither a bitfield of class READ_* constants or GAID_FOR_UPDATE
Returns
int

Definition at line 2913 of file Title.php.

◆ getLinksFrom()

MediaWiki\Title\Title::getLinksFrom ( $options = [],
$table = 'pagelinks',
$prefix = 'pl' )

Get an array of Title objects linked from this Title Also stores the IDs in the link cache.

WARNING: do not use this function on arbitrary user-supplied titles! On heavily-used templates it will max out the memory.

Parameters
array$optionsQuery option to Database::select()
string$tableTable name
string$prefixFields prefix
Returns
Title[] List of Titles linking here

Definition at line 3129 of file Title.php.

References $res, DB_REPLICA, and wfGetDB().

◆ getLinksTo()

MediaWiki\Title\Title::getLinksTo ( $options = [],
$table = 'pagelinks',
$prefix = 'pl' )

Get an array of Title objects linking to this Title Also stores the IDs in the link cache.

WARNING: do not use this function on arbitrary user-supplied titles! On heavily-used templates it will max out the memory.

Parameters
array$optionsMay be FOR UPDATE
string$tableTable name
string$prefixFields prefix
Returns
Title[]

Definition at line 3063 of file Title.php.

References $res, DB_PRIMARY, DB_REPLICA, and wfGetDB().

◆ getLinkURL()

MediaWiki\Title\Title::getLinkURL ( $query = '',
$query2 = false,
$proto = false )

Get a URL that's the simplest URL that will be valid to link, locally, to the current Title.

It includes the fragment, but does not include the server unless action=render is used (or the link is external). If there's a fragment but the prefixed text is empty, we just return a link to the fragment.

The result obviously should not be URL-escaped, but does need to be HTML-escaped if it's being output in HTML.

Parameters
string | array$query
string | string[] | false$query2
string | int | false$protoA PROTO_* constant on how the URL should be expanded, or false (default) for no expansion
See also
self::getLocalURL for the arguments.
Returns
string The URL

Definition at line 2374 of file Title.php.

◆ getLocalURL()

MediaWiki\Title\Title::getLocalURL ( $query = '',
$query2 = false )

Get a URL with no fragment or server name (relative URL) from a Title object.

If this page is generated with action=render, however, $wgServer is prepended to make an absolute URL.

See also
self::getFullURL to always get an absolute URL.
self::getLinkURL to always get a URL that's the simplest URL that will be valid to link, locally, to the current Title.
self::newFromText to produce a Title object.
Parameters
string | array$queryAn optional query string, not used for interwiki links. Can be specified as an associative array as well, e.g., [ 'action' => 'edit' ] (keys and values will be URL-escaped). Some query patterns will trigger various shorturl path replacements.
string | string[] | false$query2An optional secondary query array. This one MUST be an array. If a string is passed it will be interpreted as a deprecated variant argument and urlencoded into a variant= argument. This second query argument will be added to the $query The second parameter is deprecated since 1.19. Pass it as a key,value pair in the first parameter array instead.
Returns
string

Definition at line 2280 of file Title.php.

References $matches, $wgActionPaths, $wgArticlePath, $wgMainPageIsDomainRoot, $wgScript, $wgVariantArticlePath, wfAppendQuery(), and wfUrlencode().

◆ getNamespace()

◆ getNamespaceKey()

MediaWiki\Title\Title::getNamespaceKey ( $prepend = 'nstab-')

Generate strings used for xml 'id' names in monobook tabs.

Parameters
string$prependDefaults to 'nstab-'
Returns
string XML 'id' name

Definition at line 3789 of file Title.php.

◆ getNsText()

MediaWiki\Title\Title::getNsText ( )

Get the namespace text.

Returns
string|false Namespace name with underscores (not spaces), e.g. 'User_talk'

Definition at line 1193 of file Title.php.

References NS_MAIN, and wfDebug().

◆ getOtherPage()

MediaWiki\Title\Title::getOtherPage ( )

Get the other title for this page, if this is a subject page get the talk page, if it is a subject page get the talk page.

Deprecated
since 1.34, use NamespaceInfo::getAssociatedPage
Since
1.25
Exceptions
MWExceptionIf the page doesn't have an other page
Returns
Title

Definition at line 1773 of file Title.php.

◆ getPageLanguage()

MediaWiki\Title\Title::getPageLanguage ( )

Get the language in which the content of this page is written in wikitext.

Defaults to content language, but in certain cases it can be e.g. $wgLang (such as special pages, which are in the user language).

Since
1.18
Returns
Language|StubUserLang

Definition at line 3984 of file Title.php.

References $wgLang, and $wgLanguageCode.

◆ getPageViewLanguage()

MediaWiki\Title\Title::getPageViewLanguage ( )

Get the language in which the content of this page is written when viewed by user.

Defaults to content language, but in certain cases it can be e.g. $wgLang (such as special pages, which are in the user language).

Since
1.20
Returns
Language|StubUserLang

Definition at line 4025 of file Title.php.

References $wgLang.

◆ getParentCategories()

MediaWiki\Title\Title::getParentCategories ( )

Get categories to which this Title belongs and return an array of categories' names.

Returns
string[] Array of parents in the form: $parent => $currentarticle

Definition at line 3303 of file Title.php.

References $dbr, $res, DB_REPLICA, NS_CATEGORY, and wfGetDB().

◆ getParentCategoryTree()

MediaWiki\Title\Title::getParentCategoryTree ( $children = [])

Get a tree of parent categories.

Parameters
array$childrenArray with the children in the keys, to check for circular refs
Returns
array Tree of parent categories

Definition at line 3338 of file Title.php.

◆ getPartialURL()

MediaWiki\Title\Title::getPartialURL ( )

Get the URL-encoded form of the main part.

Returns
string Main part of the title, URL-encoded

Definition at line 1081 of file Title.php.

◆ getPrefixedDBkey()

MediaWiki\Title\Title::getPrefixedDBkey ( )

Get the prefixed database key form.

Returns
string The prefixed title, with underscores and any interwiki and namespace prefixes

Definition at line 1911 of file Title.php.

Referenced by PPTemplateFrame_Hash\__construct(), PPFrame_Hash\loopCheck(), and LinkHolderArray\makeHolder().

◆ getPrefixedText()

MediaWiki\Title\Title::getPrefixedText ( )

Get the prefixed title with spaces.

This is the form usually used for display

Returns
string The prefixed title, with spaces

Definition at line 1923 of file Title.php.

Referenced by SpecialChangeContentModel\setParameter(), MediaWiki\Specials\SpecialMovePage\showForm(), and SpecialWhatLinksHere\wlhLink().

◆ getPrefixedURL()

MediaWiki\Title\Title::getPrefixedURL ( )

Get a URL-encoded title (not an actual URL) including interwiki.

Returns
string The URL-encoded form

Definition at line 2156 of file Title.php.

References wfUrlencode().

◆ getRedirectsHere()

MediaWiki\Title\Title::getRedirectsHere ( $ns = null)

Get all extant redirects to this Title.

Parameters
int | null$nsSingle namespace to consider; null to consider all namespaces
Returns
Title[]

Definition at line 3818 of file Title.php.

References $dbr, $res, DB_REPLICA, and wfGetDB().

◆ getRestrictionExpiry()

MediaWiki\Title\Title::getRestrictionExpiry ( $action)

Get the expiry time for the restriction against a given action.

Deprecated
since 1.37, hard deprecated 1.40, use RestrictionStore::getRestrictionExpiry instead
Parameters
string$action
Returns
string|bool 14-char timestamp, or 'infinity' if the page is protected forever or not protected at all, or false if the action is not recognised.

Definition at line 2637 of file Title.php.

References wfDeprecated().

◆ getRestrictions()

MediaWiki\Title\Title::getRestrictions ( $action)

Accessor/initialisation for mRestrictions.

Deprecated
since 1.37, hard deprecated 1.40, use RestrictionStore::getRestrictions instead
Parameters
string$actionAction that permission needs to be checked for
Returns
array Restriction levels needed to take the action. All levels are required. Note that restriction levels are normally user rights, but 'sysop' and 'autoconfirmed' are also allowed for backwards compatibility. These should be mapped to 'editprotected' and 'editsemiprotected' respectively.

Definition at line 2609 of file Title.php.

References wfDeprecated().

◆ getRestrictionTypes()

MediaWiki\Title\Title::getRestrictionTypes ( )

Returns restriction types for the current Title.

Deprecated
since 1.37, hard deprecated 1.40, use RestrictionStore::listApplicableRestrictionTypes instead
Returns
array Applicable restriction types

Definition at line 2466 of file Title.php.

References wfDeprecated().

◆ getRootText()

MediaWiki\Title\Title::getRootText ( )

Get the root page name text without a namespace, i.e.

the leftmost part before any slashes

Note
the return value may contain trailing whitespace and is thus not safe for use with makeTitle or TitleValue.
Example:
Title::newFromText('User:Foo/Bar/Baz')->getRootText();
# returns: 'Foo'
Returns
string Root name
Since
1.20

Definition at line 2007 of file Title.php.

◆ getRootTitle()

MediaWiki\Title\Title::getRootTitle ( )

Get the root page name title, i.e.

the leftmost part before any slashes

Example:
Title::newFromText('User:Foo/Bar/Baz')->getRootTitle();
# returns: Title{User:Foo}
Returns
Title
Since
1.20

Definition at line 2034 of file Title.php.

References $title.

◆ getSelectFields()

static MediaWiki\Title\Title::getSelectFields ( )
staticprotected

Returns a list of fields that are to be selected for initializing Title objects.

Deprecated
since 1.36, use PageStore::newSelectQueryBuilder() instead. Hard deprecated in 1.39, remove in 1.40
Returns
array

Definition at line 539 of file Title.php.

References wfDeprecated().

◆ getSkinFromConfigSubpage()

MediaWiki\Title\Title::getSkinFromConfigSubpage ( )

Trim down a .css, .json, or .js subpage title to get the corresponding skin name.

Returns
string Containing skin name from .css, .json, or .js subpage title
Since
1.31

Definition at line 1523 of file Title.php.

◆ getSubjectNsText()

MediaWiki\Title\Title::getSubjectNsText ( )

Get the namespace text of the subject (rather than talk) page.

Returns
string Namespace name with underscores (not spaces)

Definition at line 1223 of file Title.php.

◆ getSubjectPage()

MediaWiki\Title\Title::getSubjectPage ( )

Get a title object associated with the subject page of this talk page.

Deprecated
since 1.34, use NamespaceInfo::getSubjectPage
Returns
Title The object for the subject page

Definition at line 1716 of file Title.php.

References $title.

◆ getSubpage()

MediaWiki\Title\Title::getSubpage ( $text)

Get the title for a subpage of the current page.

Example:
Title::newFromText('User:Foo/Bar/Baz')->getSubpage("Asdf");
# returns: Title{User:Foo/Bar/Baz/Asdf}
Parameters
string$textThe subpage name to add to the title
Returns
Title|null Subpage title, or null on an error
Since
1.20

Definition at line 2131 of file Title.php.

◆ getSubpages()

MediaWiki\Title\Title::getSubpages ( $limit = -1)

Get all subpages of this page.

Parameters
int$limitMaximum number of subpages to fetch; -1 for no limit
Returns
TitleArray|array TitleArray, or empty array if this page's namespace doesn't allow subpages

Definition at line 2770 of file Title.php.

◆ getSubpageText()

MediaWiki\Title\Title::getSubpageText ( )

Get the lowest-level subpage name, i.e.

the rightmost part after any slashes

Example:
Title::newFromText('User:Foo/Bar/Baz')->getSubpageText();
# returns: "Baz"
Returns
string Subpage name

Definition at line 2104 of file Title.php.

◆ getSubpageUrlForm()

MediaWiki\Title\Title::getSubpageUrlForm ( )

Get a URL-encoded form of the subpage text.

Returns
string URL-encoded subpage name

Definition at line 2145 of file Title.php.

References wfUrlencode().

◆ getTalkNsText()

MediaWiki\Title\Title::getTalkNsText ( )

Get the namespace text of the talk page.

Returns
string Namespace name with underscores (not spaces)

Definition at line 1234 of file Title.php.

◆ getTalkPage()

MediaWiki\Title\Title::getTalkPage ( )

Get a Title object associated with the talk page of this article.

Deprecated
since 1.34, use getTalkPageIfDefined() or NamespaceInfo::getTalkPage() with NamespaceInfo::canHaveTalkPage(). Note that the new method will throw if asked for the talk page of a section-only link, or of an interwiki link.
Returns
Title The object for the talk page
Exceptions
MWExceptionif $target doesn't have talk pages, e.g. because it's in NS_SPECIAL or because it's a relative link, or an interwiki link.

Definition at line 1671 of file Title.php.

References $title.

Referenced by MediaWiki\Specials\SpecialMovePage\showForm().

◆ getTalkPageIfDefined()

MediaWiki\Title\Title::getTalkPageIfDefined ( )

Get a Title object associated with the talk page of this article, if such a talk page can exist.

Since
1.30
Returns
Title|null The object for the talk page, or null if no associated talk page can exist, according to canHaveTalkPage().

Definition at line 1701 of file Title.php.

◆ getTemplateLinksFrom()

MediaWiki\Title\Title::getTemplateLinksFrom ( $options = [])

Get an array of Title objects used on this Title as a template Also stores the IDs in the link cache.

WARNING: do not use this function on arbitrary user-supplied titles! On heavily-used templates it will max out the memory.

Parameters
array$optionsMay be FOR UPDATE
Returns
Title[]

Definition at line 3195 of file Title.php.

◆ getTemplateLinksTo()

MediaWiki\Title\Title::getTemplateLinksTo ( $options = [])

Get an array of Title objects using this Title as a template Also stores the IDs in the link cache.

WARNING: do not use this function on arbitrary user-supplied titles! On heavily-used templates it will max out the memory.

Parameters
array$optionsQuery option to Database::select()
Returns
Title[]

Definition at line 3113 of file Title.php.

◆ getText()

MediaWiki\Title\Title::getText ( )

Get the text form (spaces not underscores) of the main part.

Returns
string Main part of the title

Implements MediaWiki\Linker\LinkTarget.

Definition at line 1072 of file Title.php.

Referenced by TraditionalImageGallery\getCaptionHtml(), and MediaWiki\Specials\SpecialMovePage\showForm().

◆ getTitleProtection()

MediaWiki\Title\Title::getTitleProtection ( )

Is this title subject to title protection? Title protection is the one applied against creation of such title.

Deprecated
since 1.37, use RestrictionStore::getRestrictions() instead
Returns
array|bool An associative array representing any existent title protection, or false if there's none.

Definition at line 2482 of file Title.php.

◆ getTitleValue()

MediaWiki\Title\Title::getTitleValue ( )

Get a TitleValue object representing this Title.

Note
Not all valid Titles have a corresponding valid TitleValue (e.g. TitleValues cannot represent page-local links that have a fragment but no title text).
Returns
TitleValue|null

Definition at line 1049 of file Title.php.

References wfDebug().

◆ getTouched()

MediaWiki\Title\Title::getTouched ( $flags = self::READ_NORMAL)

Get the last touched timestamp.

Parameters
int$flagsone of the READ_XXX constants. For historical reasons, an IDatabase instance is also accepted here. If an IDatabase is passed, a deprecation warning is triggered, caches will be bypassed, and the primary database connection will be used. However, the IDatabase instance itself will be ignored.
Returns
string|false Last-touched timestamp

Definition at line 3769 of file Title.php.

References wfDeprecatedMsg().

◆ getTransWikiID()

MediaWiki\Title\Title::getTransWikiID ( )

Returns the DB name of the distant wiki which owns the object.

Returns
string|false The DB name

Definition at line 1032 of file Title.php.

◆ getWikiId()

MediaWiki\Title\Title::getWikiId ( )

Returns false to indicate that this Title belongs to the local wiki.

Note
The behavior of this method is considered undefined for interwiki links. At the moment, this method always returns false. But this may change in the future.
Since
1.36
Returns
string|false Always self::LOCAL

Implements MediaWiki\Page\PageReference.

Definition at line 4212 of file Title.php.

◆ hasContentModel()

MediaWiki\Title\Title::hasContentModel ( $id)

Convenience method for checking a title's content model name.

Parameters
string$idThe content model ID (use the CONTENT_MODEL_XXX constants).
Returns
bool True if $this->getContentModel() == $id

Definition at line 1147 of file Title.php.

◆ hasDeletedEdits()

MediaWiki\Title\Title::hasDeletedEdits ( )

Is there a version of this page in the deletion archive?

Since
1.36
Returns
bool

Definition at line 2845 of file Title.php.

References $dbr, DB_REPLICA, NS_FILE, and wfGetDB().

◆ hasFragment()

MediaWiki\Title\Title::hasFragment ( )

Check if a Title fragment is set.

Returns
bool
Since
1.23

Implements MediaWiki\Linker\LinkTarget.

Definition at line 1810 of file Title.php.

Referenced by CoreParserFunctions\displaytitle().

◆ hasSourceText()

MediaWiki\Title\Title::hasSourceText ( )

Does this page have source text?

Returns
bool

Definition at line 3608 of file Title.php.

References NS_MEDIAWIKI, and wfMessage().

◆ hasSubjectNamespace()

MediaWiki\Title\Title::hasSubjectNamespace ( $ns)

Returns true if the title has the same subject namespace as the namespace specified.

For example this method will take NS_USER and return true if namespace is either NS_USER or NS_USER_TALK since both of them have NS_USER as their subject namespace.

This is MUCH simpler than individually testing for equivalence against both NS_USER and NS_USER_TALK, and is also forward compatible.

Since
1.19
Parameters
int$ns
Returns
bool

Definition at line 1394 of file Title.php.

◆ hasSubpages()

MediaWiki\Title\Title::hasSubpages ( )

Does this have subpages? (Warning, usually requires an extra DB query.)

Returns
bool

Definition at line 2742 of file Title.php.

◆ inNamespace()

MediaWiki\Title\Title::inNamespace ( int $ns)

Returns true if the title is inside the specified namespace.

Parameters
int$nsThe namespace
Returns
bool
Since
1.19

Implements MediaWiki\Linker\LinkTarget.

Definition at line 1355 of file Title.php.

◆ inNamespaces()

MediaWiki\Title\Title::inNamespaces ( $namespaces)

Returns true if the title is inside one of the specified namespaces.

Parameters
int|int[]...$namespaces The namespaces to check for
Returns
bool
Since
1.19

Definition at line 1367 of file Title.php.

◆ invalidateCache()

MediaWiki\Title\Title::invalidateCache ( $purgeTime = null)

Updates page_touched for this page; called from LinksUpdate.php.

Parameters
string | null$purgeTime[optional] TS_MW timestamp
Returns
bool True if the update succeeded

Definition at line 3702 of file Title.php.

References Wikimedia\Rdbms\Database\DbQuoter\addQuotes(), DB_PRIMARY, Wikimedia\Rdbms\IReadableDatabase\getDomainID(), Wikimedia\Rdbms\Platform\ISQLPlatform\timestamp(), Wikimedia\Rdbms\IDatabase\update(), and wfGetDB().

◆ isAlwaysKnown()

MediaWiki\Title\Title::isAlwaysKnown ( )

Should links to this title be shown as potentially viewable (i.e.

as "bluelinks"), even if there's no record by this title in the page table?

This function is semi-deprecated for public use, as well as somewhat misleadingly named. You probably just want to call isKnown(), which calls this function internally.

(ISSUE: Most of these checks are cheap, but the file existence check can potentially be quite expensive. Including it here fixes a lot of existing code, but we might want to add an optional parameter to skip it and any other expensive checks.)

Returns
bool

Definition at line 3545 of file Title.php.

References NS_FILE, NS_MAIN, NS_MEDIA, NS_MEDIAWIKI, and NS_SPECIAL.

◆ isBigDeletion()

MediaWiki\Title\Title::isBigDeletion ( )

Check whether the number of revisions of this page surpasses $wgDeleteRevisionsLimit.

Deprecated
since 1.37 External callers shouldn't need to know about this.
Returns
bool

Definition at line 3393 of file Title.php.

References $dbr, $wgDeleteRevisionsLimit, DB_REPLICA, and wfGetDB().

◆ isCascadeProtected()

MediaWiki\Title\Title::isCascadeProtected ( )

Cascading protection: Return true if cascading restrictions apply to this page, false if not.

Deprecated
since 1.37, hard deprecated 1.40, use RestrictionStore::isCascadeProtected instead
Returns
bool If the page is subject to cascading restrictions.

Definition at line 2535 of file Title.php.

References wfDeprecated().

◆ isContentPage()

MediaWiki\Title\Title::isContentPage ( )

Is this Title in a namespace which contains content? In other words, is this a content page, for the purposes of calculating statistics, etc?

Returns
bool

Definition at line 1406 of file Title.php.

◆ isConversionTable()

MediaWiki\Title\Title::isConversionTable ( )

Is this a conversion table for the LanguageConverter?

Returns
bool

Definition at line 1464 of file Title.php.

References NS_MEDIAWIKI.

◆ isDeleted()

MediaWiki\Title\Title::isDeleted ( )

Is there a version of this page in the deletion archive?

Deprecated
since 1.36. Use self::getDeletedEditsCount()
Returns
int The number of archived revisions

Definition at line 2799 of file Title.php.

◆ isDeletedQuick()

MediaWiki\Title\Title::isDeletedQuick ( )

Is there a version of this page in the deletion archive?

Deprecated
since 1.36, Use self::hasDeletedEdits()
Returns
bool

Definition at line 2835 of file Title.php.

◆ isExternal()

MediaWiki\Title\Title::isExternal ( )

Is this Title interwiki?

Returns
bool

Implements MediaWiki\Linker\LinkTarget.

Definition at line 989 of file Title.php.

Referenced by LinkHolderArray\makeHolder().

◆ isKnown()

MediaWiki\Title\Title::isKnown ( )

Does this title refer to a page that can (or might) be meaningfully viewed? In particular, this function may be used to determine if links to the title should be rendered as "bluelinks" (as opposed to "redlinks" to non-existent pages).

Adding something else to this function will cause inconsistency since LinkHolderArray calls isAlwaysKnown() and does its own page existence check.

Returns
bool

Definition at line 3599 of file Title.php.

◆ isLocal()

MediaWiki\Title\Title::isLocal ( )

Determine whether the object refers to a page within this project (either this wiki or a wiki with a local interwiki, see https://www.mediawiki.org/wiki/Manual:Interwiki_table#iw_local )

Returns
bool True if this is an in-project interwiki link or a wikilink, false otherwise

Definition at line 974 of file Title.php.

◆ isMainPage()

MediaWiki\Title\Title::isMainPage ( )

Is this the mainpage?

See also
T302186
Since
1.18
Returns
bool

Definition at line 1438 of file Title.php.

◆ isMovable()

MediaWiki\Title\Title::isMovable ( )

Would anybody with sufficient privileges be able to move this page? Some pages just aren't movable.

Returns
bool

Definition at line 1417 of file Title.php.

◆ isNewPage()

MediaWiki\Title\Title::isNewPage ( $flags = self::READ_NORMAL)

Check if this is a new page.

Note
This returns false if the page does not exist.
Parameters
int$flagsone of the READ_XXX constants.
Returns
bool

Definition at line 3382 of file Title.php.

◆ isProtected()

MediaWiki\Title\Title::isProtected ( $action = '')

Does the title correspond to a protected article?

Deprecated
since 1.37, hard deprecated 1.40, use RestrictionStore::isProtected instead
Parameters
string$actionThe action the page is protected from, by default checks all actions.
Returns
bool

Definition at line 2521 of file Title.php.

References wfDeprecated().

◆ isRawHtmlMessage()

MediaWiki\Title\Title::isRawHtmlMessage ( )

Is this a message which can contain raw HTML?

Returns
bool
Since
1.32

Definition at line 1640 of file Title.php.

References $wgRawHtmlMessages, and NS_MEDIAWIKI.

◆ isRedirect()

MediaWiki\Title\Title::isRedirect ( $flags = 0)

Is this an article that is a redirect page? Uses link cache, adding it if necessary.

This is intended to provide fast access to page_is_redirect for linking. In rare cases, there might not be a valid target in the redirect table even though this function returns true.

To find a redirect target, just call WikiPage::getRedirectTarget() and check if it returns null, there's no need to call this first.

Parameters
int$flagsEither a bitfield of class READ_* constants or GAID_FOR_UPDATE
Returns
bool

Definition at line 2898 of file Title.php.

◆ isSameLinkAs()

MediaWiki\Title\Title::isSameLinkAs ( LinkTarget $other)
See also
LinkTarget::isSameLinkAs()
Since
1.36
Parameters
LinkTarget$other
Returns
bool

Implements MediaWiki\Linker\LinkTarget.

Definition at line 3470 of file Title.php.

◆ isSamePageAs()

MediaWiki\Title\Title::isSamePageAs ( PageReference $other)
See also
PageReference::isSamePageAs()
Since
1.36
Parameters
PageReference$other
Returns
bool

Implements MediaWiki\Page\PageReference.

Definition at line 3486 of file Title.php.

◆ isSemiProtected()

MediaWiki\Title\Title::isSemiProtected ( $action = 'edit')

Is this page "semi-protected" - the only protection levels are listed in $wgSemiprotectedRestrictionLevels?

Deprecated
since 1.37, hard deprecated 1.40, use RestrictionStore::isSemiProtected instead
Parameters
string$actionAction to check (default: edit)
Returns
bool

Definition at line 2505 of file Title.php.

References wfDeprecated().

◆ isSingleRevRedirect()

MediaWiki\Title\Title::isSingleRevRedirect ( )

Locks the page row and check if this page is single revision redirect.

This updates the cached fields of this instance via Title::loadFromRow()

Returns
bool

Definition at line 3264 of file Title.php.

References DB_PRIMARY, and wfGetDB().

◆ isSiteConfigPage()

MediaWiki\Title\Title::isSiteConfigPage ( )

Could this MediaWiki namespace page contain custom CSS, JSON, or JavaScript for the global UI.

This is generally true for pages in the MediaWiki namespace having CONTENT_MODEL_CSS, CONTENT_MODEL_JSON, or CONTENT_MODEL_JAVASCRIPT.

This method does not return true for per-user JS/JSON/CSS. Use isUserConfigPage() for that!

Note that this method should not return true for pages that contain and show "inactive" CSS, JSON, or JS.

Returns
bool
Since
1.31

Definition at line 1495 of file Title.php.

◆ isSiteCssConfigPage()

MediaWiki\Title\Title::isSiteCssConfigPage ( )

Is this a sitewide CSS "config" page?

Returns
bool
Since
1.32

Definition at line 1586 of file Title.php.

References CONTENT_MODEL_CSS, and NS_MEDIAWIKI.

◆ isSiteJsConfigPage()

MediaWiki\Title\Title::isSiteJsConfigPage ( )

Is this a sitewide JS "config" page?

Returns
bool
Since
1.31

Definition at line 1622 of file Title.php.

References CONTENT_MODEL_JAVASCRIPT, and NS_MEDIAWIKI.

◆ isSiteJsonConfigPage()

MediaWiki\Title\Title::isSiteJsonConfigPage ( )

Is this a sitewide JSON "config" page?

Returns
bool
Since
1.32

Definition at line 1604 of file Title.php.

References CONTENT_MODEL_JSON, and NS_MEDIAWIKI.

◆ isSpecial()

MediaWiki\Title\Title::isSpecial ( $name)

Returns true if this title resolves to the named special page.

Parameters
string$nameThe special page name
Returns
bool

Definition at line 1316 of file Title.php.

◆ isSpecialPage()

MediaWiki\Title\Title::isSpecialPage ( )

Returns true if this is a special page.

Returns
bool

Definition at line 1306 of file Title.php.

References NS_SPECIAL.

Referenced by SkinTemplate\buildPersonalUrls().

◆ isSubpage()

MediaWiki\Title\Title::isSubpage ( )

Is this a subpage?

Returns
bool

Definition at line 1452 of file Title.php.

◆ isSubpageOf()

MediaWiki\Title\Title::isSubpageOf ( Title $title)

Check if this title is a subpage of another title.

Parameters
Title$title
Returns
bool

Definition at line 3507 of file Title.php.

References $title.

◆ isTalkPage()

MediaWiki\Title\Title::isTalkPage ( )

Is this a talk page of some sort?

Returns
bool

Definition at line 1655 of file Title.php.

◆ isTrans()

MediaWiki\Title\Title::isTrans ( )

Determine whether the object refers to a page within this project and is transcludable.

Returns
bool True if this is transcludable

Definition at line 1019 of file Title.php.

◆ isUserConfigPage()

MediaWiki\Title\Title::isUserConfigPage ( )

Is this a "config" (.css, .json, or .js) sub-page of a user page?

Returns
bool
Since
1.31

Definition at line 1509 of file Title.php.

◆ isUserCssConfigPage()

MediaWiki\Title\Title::isUserCssConfigPage ( )

Is this a CSS "config" sub-page of a user page?

Returns
bool
Since
1.31

Definition at line 1544 of file Title.php.

References CONTENT_MODEL_CSS, and NS_USER.

◆ isUserJsConfigPage()

MediaWiki\Title\Title::isUserJsConfigPage ( )

Is this a JS "config" sub-page of a user page?

Returns
bool
Since
1.31

Definition at line 1572 of file Title.php.

References CONTENT_MODEL_JAVASCRIPT, and NS_USER.

◆ isUserJsonConfigPage()

MediaWiki\Title\Title::isUserJsonConfigPage ( )

Is this a JSON "config" sub-page of a user page?

Returns
bool
Since
1.31

Definition at line 1558 of file Title.php.

References CONTENT_MODEL_JSON, and NS_USER.

◆ isValid()

MediaWiki\Title\Title::isValid ( )

Returns true if the title is a valid link target, and that it has been properly normalized.

This method checks that the title is syntactically valid, and that the namespace it refers to exists.

Titles constructed using newFromText() or makeTitleSafe() are always valid.

Note
Code that wants to check whether the title can represent a page that can be created and edited should use canExist() instead. Examples of valid titles that cannot "exist" are Special pages, interwiki links, and on-page section links that only have the fragment part set.
See also
canExist()
Returns
bool

Definition at line 935 of file Title.php.

◆ isValidRedirectTarget()

MediaWiki\Title\Title::isValidRedirectTarget ( )

Check if this Title is a valid redirect target.

Returns
bool

Definition at line 3854 of file Title.php.

References $wgInvalidRedirectTargets.

Referenced by WikitextContent\getRedirectTargetAndText(), and XmlDumpWriter\openPage().

◆ isWikitextPage()

MediaWiki\Title\Title::isWikitextPage ( )

Does that page contain wikitext, or it is JS, CSS or whatever?

Returns
bool

Definition at line 1477 of file Title.php.

References CONTENT_MODEL_WIKITEXT.

◆ legalChars()

static MediaWiki\Title\Title::legalChars ( )
static

Get a regex character class describing the legal characters in a link.

Returns
string The list of characters, not delimited

Definition at line 767 of file Title.php.

References $wgLegalTitleChars.

◆ loadFromRow()

MediaWiki\Title\Title::loadFromRow ( $row)

Load Title object fields from a DB row.

If false is given, the title will be treated as non-existing.

Parameters
stdClass | false$rowDatabase row

Definition at line 618 of file Title.php.

◆ loadRestrictions()

MediaWiki\Title\Title::loadRestrictions ( $flags = 0)

Load restrictions from the page_restrictions table.

Deprecated
since 1.37, no public replacement
Parameters
int$flagsA bit field. If self::READ_LATEST is set, skip replicas and read from the primary DB.

Definition at line 2682 of file Title.php.

◆ loadRestrictionsFromRows()

MediaWiki\Title\Title::loadRestrictionsFromRows ( $rows)

Compiles list of active page restrictions from both page table (pre 1.10) and page_restrictions table for this existing page.

Public for usage by LiquidThreads.

Deprecated
since 1.37, hard deprecated 1.40, use RestrictionStore::loadRestrictionsFromRows instead
Parameters
stdClass[]$rowsArray of db result objects

Definition at line 2667 of file Title.php.

References wfDeprecated().

◆ makeName()

static MediaWiki\Title\Title::makeName ( $ns,
$title,
$fragment = '',
$interwiki = '',
$canonicalNamespace = false )
static

Make a prefixed DB key from a DB key and a namespace index.

Parameters
int$nsNumerical representation of the namespace
string$titleThe DB key form the title
string$fragmentThe link fragment (after the "#")
string$interwikiThe interwiki prefix
bool$canonicalNamespaceIf true, use the canonical name for $ns instead of the localized version.
Returns
string The prefixed form of the title

Definition at line 887 of file Title.php.

References $title.

◆ makeTitle()

static MediaWiki\Title\Title::makeTitle ( $ns,
$title,
$fragment = '',
$interwiki = '' )
static

Create a new Title from a namespace index and a DB key.

It's assumed that $ns and $title are safe, for instance when they came directly from the database or a special page name, not from user input.

No validation is applied. For convenience, spaces are normalized to underscores, so that e.g. user_text fields can be used directly.

Note
This method may return Title objects that are "invalid" according to the isValid() method. This is usually caused by configuration changes: e.g. a namespace that was once defined is no longer configured, or a character that was once allowed in titles is now forbidden.
Parameters
int$nsThe namespace of the article
string$titleThe unprefixed database key form
string$fragmentThe link fragment (after the "#")
string$interwikiThe interwiki prefix
Returns
Title The new object

Definition at line 671 of file Title.php.

References $t, $title, and wfUrlencode().

◆ makeTitleSafe()

static MediaWiki\Title\Title::makeTitleSafe ( $ns,
$title,
$fragment = '',
$interwiki = '' )
static

Create a new Title from a namespace index and a DB key.

The parameters will be checked for validity, which is a bit slower than makeTitle() but safer for user-provided data.

The Title object returned by this method is guaranteed to be valid. Call canExist() to check if the Title represents an editable page.

Parameters
int$nsThe namespace of the article
string$titleDatabase key form
string$fragmentThe link fragment (after the "#")
string$interwikiInterwiki prefix
Returns
Title|null The new object, or null on an error

Definition at line 697 of file Title.php.

References $t, and $title.

◆ newFromDBkey()

static MediaWiki\Title\Title::newFromDBkey ( $key)
static

Create a new Title from a prefixed DB key.

Parameters
string$keyThe database key, which has underscores instead of spaces, possibly including namespace and interwiki prefixes
Returns
Title|null Title, or null on an error

Definition at line 274 of file Title.php.

References $t.

◆ newFromID()

static MediaWiki\Title\Title::newFromID ( $id,
$flags = 0 )
static

Create a new Title from an article ID.

Parameters
int$idThe page_id corresponding to the Title to create
int$flagsBitfield of class READ_* constants
Returns
Title|null The new object, or null on an error

Definition at line 551 of file Title.php.

References $title, and wfGetDB().

◆ newFromIDs()

static MediaWiki\Title\Title::newFromIDs ( $ids)
static

Make an array of titles from an array of IDs.

Parameters
int[]$idsArray of IDs
Returns
Title[] Array of Titles
Deprecated
since 1.38 use a PageStore QueryBuilder instead

Definition at line 578 of file Title.php.

References $dbr, $res, DB_REPLICA, wfDeprecated(), and wfGetDB().

◆ newFromLinkTarget()

static MediaWiki\Title\Title::newFromLinkTarget ( LinkTarget $linkTarget,
$forceClone = '' )
static

Returns a Title given a LinkTarget.

If the given LinkTarget is already a Title instance, that instance is returned, unless $forceClone is "clone". If $forceClone is "clone" and the given LinkTarget is already a Title instance, that instance is copied using the clone operator.

Parameters
LinkTarget$linkTargetAssumed to be safe.
string$forceCloneset to NEW_CLONE to ensure a fresh instance is returned.
Returns
Title

Definition at line 315 of file Title.php.

References MediaWiki\Linker\LinkTarget\getFragment(), MediaWiki\Linker\LinkTarget\getInterwiki(), MediaWiki\Linker\LinkTarget\getNamespace(), and MediaWiki\Linker\LinkTarget\getText().

◆ newFromRow()

static MediaWiki\Title\Title::newFromRow ( $row)
static

Make a Title object from a DB row.

Parameters
stdClass$rowObject database row (needs at least page_title,page_namespace)
Returns
Title

Definition at line 606 of file Title.php.

References $t.

Referenced by MediaWiki\Title\TitleArrayFromResult\setCurrent().

◆ newFromText()

static MediaWiki\Title\Title::newFromText ( $text,
$defaultNamespace = NS_MAIN )
static

Create a new Title from text, such as what one would find in a link.

Decodes any HTML entities in the text. Titles returned by this method are guaranteed to be valid. Call canExist() to check if the Title represents an editable page.

Note
The Title instance returned by this method is not guaranteed to be a fresh instance. It may instead be a cached instance created previously, with references to it remaining elsewhere.
Parameters
string | int | null$textThe link text; spaces, prefixes, and an initial ':' indicating the main namespace are accepted.
int$defaultNamespaceThe namespace to use if none is specified by a prefix. If you want to force a specific namespace even if $text might begin with a namespace prefix, use makeTitle() or makeTitleSafe().
Exceptions
InvalidArgumentException
Returns
Title|null Title or null if the Title could not be parsed because it is invalid.

Definition at line 403 of file Title.php.

◆ newFromTextThrow()

static MediaWiki\Title\Title::newFromTextThrow ( $text,
$defaultNamespace = NS_MAIN )
static

Like Title::newFromText(), but throws MalformedTitleException when the title is invalid, rather than returning null.

Titles returned by this method are guaranteed to be valid. Call canExist() to check if the Title represents an editable page.

Note
The Title instance returned by this method is not guaranteed to be a fresh instance. It may instead be a cached instance created previously, with references to it remaining elsewhere.
See also
Title::newFromText
Since
1.25
Parameters
string$textTitle text to check
int$defaultNamespace
Exceptions
MalformedTitleExceptionIf the title is invalid.
Returns
Title

Definition at line 438 of file Title.php.

References $t, and NS_MAIN.

◆ newFromTitleValue()

static MediaWiki\Title\Title::newFromTitleValue ( TitleValue $titleValue,
$forceClone = '' )
static

Returns a Title given a TitleValue.

If the given TitleValue is already a Title instance, that instance is returned, unless $forceClone is "clone". If $forceClone is "clone" and the given TitleValue is already a Title instance, that instance is copied using the clone operator.

Deprecated
since 1.34, use newFromLinkTarget or castFromLinkTarget. Hard deprecated in 1.39.
Parameters
TitleValue$titleValueAssumed to be safe.
string$forceCloneset to NEW_CLONE to ensure a fresh instance is returned.
Returns
Title

Definition at line 299 of file Title.php.

References wfDeprecated().

◆ newFromURL()

static MediaWiki\Title\Title::newFromURL ( $url)
static

THIS IS NOT THE FUNCTION YOU WANT.

Use Title::newFromText().

Example of wrong and broken code: $title = Title::newFromURL( $request->getText( 'title' ) );

Example of right code: $title = Title::newFromText( $request->getText( 'title' ) );

Create a new Title from URL-encoded text. Ensures that the given title's length does not exceed the maximum.

Parameters
string$urlThe title, as might be taken from a URL
Returns
Title|null The new object, or null on an error

Definition at line 500 of file Title.php.

References $t.

◆ newMainPage()

static MediaWiki\Title\Title::newMainPage ( MessageLocalizer $localizer = null)
static

Create a new Title for the Main Page.

This uses the 'mainpage' interface message, which could be specified in $wgForceUIMsgAsContentMsg. If that is the case, then calling this method will use the user language, which would involve initialising the session via RequestContext::getMain()->getLanguage(). For session-less endpoints, be sure to pass in a MessageLocalizer (such as your own RequestContext or ResourceLoader Context) to prevent an error.

Note
The Title instance returned by this method is not guaranteed to be a fresh instance. It may instead be a cached instance created previously, with references to it remaining elsewhere.
Parameters
MessageLocalizer | null$localizerAn optional context to use (since 1.34)
Returns
Title

Definition at line 733 of file Title.php.

References $title, and wfMessage().

◆ pageCond()

MediaWiki\Title\Title::pageCond ( )

Get an associative array for selecting this title from the "page" table.

Returns
array Array suitable for the $where parameter of DB::select()

Definition at line 3365 of file Title.php.

◆ purgeExpiredRestrictions()

static MediaWiki\Title\Title::purgeExpiredRestrictions ( )
static

Purge expired restrictions from the page_restrictions table.

This will purge no more than $wgUpdateRowsPerQuery page_restrictions rows

Definition at line 2701 of file Title.php.

References Wikimedia\Rdbms\Database\DbQuoter\addQuotes(), DB_PRIMARY, Wikimedia\Rdbms\IDatabase\delete(), Wikimedia\Rdbms\IReadableDatabase\selectFieldValues(), Wikimedia\Rdbms\Platform\ISQLPlatform\timestamp(), and wfGetDB().

◆ purgeSquid()

MediaWiki\Title\Title::purgeSquid ( )

Purge all applicable CDN URLs.

Deprecated
since 1.35 Use HtmlCacheUpdater

Definition at line 3252 of file Title.php.

◆ resetArticleID()

MediaWiki\Title\Title::resetArticleID ( $id)

Inject a page ID, reset DB-loaded fields, and clear the link cache for this title.

This can be called on page insertion to allow loading of the new page_id without having to create a new Title instance. Likewise with deletion.

This is also used during page moves, to reflect the change in the relationship between article ID and title text.

Note
This overrides Title::setContentModel()
Parameters
int | bool$idPage ID, 0 for non-existent, or false for "unknown" (lazy-load)

Definition at line 2956 of file Title.php.

◆ setContentModel()

MediaWiki\Title\Title::setContentModel ( $model)

Set a proposed content model for the page for permissions checking.

This does not actually change the content model of a title in the DB. It only affects this particular Title instance. The content model is forced to remain this value until another setContentModel() call.

ContentHandler::canBeUsedOn() should be checked before calling this if there is any doubt regarding the applicability of the content model

Warning
This must only be used if the caller controls the further use of this Title object, to avoid other code unexpectedly using the new value.
Since
1.28
Parameters
string$modelCONTENT_MODEL_XXX constant

Definition at line 1167 of file Title.php.

◆ setFragment()

MediaWiki\Title\Title::setFragment ( $fragment)

Set the fragment for this title.

Removes the first character from the specified fragment before setting, so it assumes you're passing it with an initial "#".

Warning
This must only be used if the caller controls the further use of this Title object, to avoid other code unexpectedly using the new value.
Parameters
string$fragmentText

Definition at line 1844 of file Title.php.

◆ toPageIdentity()

MediaWiki\Title\Title::toPageIdentity ( )

Returns the page represented by this Title as a ProperPageIdentity.

The ProperPageIdentity returned by this method is guaranteed to be immutable. If this Title does not represent a proper page, an exception is thrown.

It is preferred to use this method rather than using the Title as a PageIdentity directly.

Returns
ProperPageIdentity
Exceptions
PreconditionExceptionif the page is not a proper page, that is, if it is a section link, interwiki link, link to a special page, or such.
Since
1.36

Definition at line 4269 of file Title.php.

◆ toPageRecord()

MediaWiki\Title\Title::toPageRecord ( $flags = 0)

Returns the page represented by this Title as a ProperPageRecord.

The PageRecord returned by this method is guaranteed to be immutable, the page is guaranteed to exist.

Note
For now, this method queries the database on every call.
Since
1.36
Parameters
int$flagsEither a bitfield of class READ_* constants or GAID_FOR_UPDATE
Returns
ExistingPageRecord
Exceptions
PreconditionExceptionif the page does not exist, or is not a proper page, that is, if it is a section link, interwiki link, link to a special page, or such.

Definition at line 4296 of file Title.php.

◆ touchLinks()

MediaWiki\Title\Title::touchLinks ( )

Update page_touched timestamps and send CDN purge messages for pages linking to this title.

May be sent to the job queue depending on the number of links. Typically called on create and delete.

Definition at line 3742 of file Title.php.

References NS_CATEGORY.

◆ wasLocalInterwiki()

MediaWiki\Title\Title::wasLocalInterwiki ( )

Was this a local interwiki link?

Returns
bool

Definition at line 1009 of file Title.php.

Member Data Documentation

◆ $mArticleID

int MediaWiki\Title\Title::$mArticleID = -1

Article ID, fetched from the link cache on demand.

Definition at line 142 of file Title.php.

◆ $mLatestID

int false MediaWiki\Title\Title::$mLatestID = false
protected

ID of most recent revision.

Definition at line 145 of file Title.php.

◆ $mLength

int MediaWiki\Title\Title::$mLength = -1
protected

The page length, 0 for special pages.

Definition at line 180 of file Title.php.

◆ $mRedirect

null bool MediaWiki\Title\Title::$mRedirect = null

Is the article at this title a redirect?

Definition at line 183 of file Title.php.

◆ $prefixedText

string null MediaWiki\Title\Title::$prefixedText = null

Text form including namespace/interwiki, initialised on demand.

Only public to share cache with TitleFormatter

Access: internal

Definition at line 170 of file Title.php.

◆ GAID_FOR_UPDATE

const MediaWiki\Title\Title::GAID_FOR_UPDATE = 512

Used to be GAID_FOR_UPDATE define().

Used with getArticleID() and friends to use the primary DB and inject it into link cache.

Deprecated
since 1.34, use Title::READ_LATEST instead.

Definition at line 101 of file Title.php.

◆ NEW_CLONE

const MediaWiki\Title\Title::NEW_CLONE = 'clone'

Flag for use with factory methods like newFromLinkTarget() that have a $forceClone parameter.

If set, the method must return a new instance. Without this flag, some factory methods may return existing instances.as

Since
1.33

Definition at line 110 of file Title.php.


The documentation for this class was generated from the following file: