MediaWiki master
MediaWiki\Page\Article Class Reference

Legacy class representing an editable page and handling UI for some page actions. More...

Inherits MediaWiki\Page\Page.

Inherited by MediaWiki\Page\CategoryPage, and MediaWiki\Page\ImagePage.

Collaboration diagram for MediaWiki\Page\Article:

Public Member Functions

 __construct (Title $title, $oldId=null)
 
 addHelpLink ( $to, $overrideBaseUrl=false)
 Adds help link with an icon via page indicators.
 
 adjustDisplayTitle (ParserOutput $pOutput)
 Adjust title for pages with displaytitle, -{T|}- or language conversion.
 
 clear ()
 
 fetchRevisionRecord ()
 Fetches the revision to work on.
 
 getActionOverrides ()
 Call to WikiPage function for backwards compatibility.
 
 getContext ()
 Gets the context this Article is executed in.
 
 getOldID ()
 
 getOldIDFromRequest ()
 Sets $this->mRedirectUrl to a correct URL if the query parameters are incorrect.
 
 getPage ()
 Get the WikiPage object of this instance.
 
 getParserOptions ()
 Get parser options suitable for rendering the primary article wikitext.
 
 getParserOutput ( $oldid=null, ?UserIdentity $user=null)
 Lightweight method to get the parser output for a page, checking the parser cache and so on.
 
 getRedirectedFrom ()
 Get the page this view was redirected from.
 
 getRevIdFetched ()
 Use this to fetch the rev ID used on page views.
 
 getRobotPolicy ( $action, ?ParserOutput $pOutput=null)
 Get the robot policy to be used for the current view.
 
 getTitle ()
 Get the title object of the article.
 
 isCurrent ()
 Returns true if the currently-referenced revision is the current edit to this page (and it exists).
 
 isFileCacheable ( $mode=HTMLFileCache::MODE_NORMAL)
 Check if the page can be cached.
 
 protect ()
 action=protect handler
 
 render ()
 Handle action=render.
 
 setContext ( $context)
 Sets the context this Article is executed in.
 
 setOldSubtitle ( $oldid=0)
 Generate the navigation links when browsing through an article revisions It shows the information as: Revision as of \<date\>; view current revision \<- Previous version | Next Version -\>
 
 setRedirectedFrom (Title $from)
 Tell the page view functions that this view was redirected from another page on the wiki.
 
 setUseLegacyPostprocCache (bool $val=true)
 By default, we do not use the postprocessing cache for legacy parses; however, we want to be able to override this for some cases (e.g.
 
 showDeletedRevisionHeader ()
 If the revision requested for view is deleted, check permissions.
 
 showMissingArticle ()
 Show the error text for a missing article.
 
 showNamespaceHeader ()
 Show a header specific to the namespace currently being viewed, such as [[MediaWiki:Subjectpageheader]] on subject pages or [[MediaWiki:Talkpageheader]] on talk pages.
 
 showPatrolFooter ()
 If patrol is possible, output a patrol UI box.
 
 showProtectionIndicator ()
 Show a lock icon above the article body if the page is protected.
 
 showRedirectedFromHeader ()
 If this request is a redirect view, send "redirected from" subtitle to the output.
 
 showViewFooter ()
 Show the footer section of an ordinary page view.
 
 unprotect ()
 action=unprotect handler (alias)
 
 view ()
 This is the default action of the index.php entry point: just view the page of the given title.
 

Static Public Member Functions

static formatRobotPolicy ( $policy)
 Converts a String robot policy into an associative array, to allow merging of several policies using array_merge().
 
static newFromID ( $id)
 Constructor from a page id.
 
static newFromTitle ( $title, IContextSource $context)
 Create an Article object of the appropriate class for the given page.
 
static newFromWikiPage (WikiPage $page, IContextSource $context)
 Create an Article object of the appropriate class for the given page.
 
static purgePatrolFooterCache ( $articleID)
 Purge the cache used to check if it is worth showing the patrol footer For example, it is done during re-uploads when file patrol is used.
 

Public Attributes

int null $mOldId
 The oldid of the article that was requested to be shown, 0 for the current revision.
 
ParserOutput null false $mParserOutput = null
 The ParserOutput generated for viewing the page, initialized by view().
 
Title null $mRedirectedFrom = null
 Title from which we were redirected here, if any.
 
string false $mRedirectUrl = false
 URL to redirect to or false if none.
 

Protected Member Functions

 isDiffOnlyView ()
 
 newPage (Title $title)
 
 showDiffPage ()
 Show a diff page according to current request variables.
 
 tryFileCache ()
 checkLastModified returns true if it has taken care of all output to the client that is necessary for this request.
 

Protected Attributes

DatabaseBlockStore $blockStore
 
IConnectionProvider $dbProvider
 
LinkRenderer $linkRenderer
 
WikiPage $mPage
 The WikiPage object of this instance.
 
RestrictionStore $restrictionStore
 
bool $viewIsRenderAction = false
 Whether render() was called.
 

Detailed Description

Legacy class representing an editable page and handling UI for some page actions.

This has largely been superseded by WikiPage, with Action subclasses for the user interface of page actions, and service classes for their backend logic.

Todo

Move and refactor remaining code

Deprecate

Definition at line 64 of file Article.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Page\Article::__construct ( Title $title,
$oldId = null )
Parameters
Title$title
int | null$oldIdRevision ID, null to fetch from request, zero for current

Definition at line 140 of file Article.php.

References MediaWiki\MediaWikiServices\getInstance(), MediaWiki\Page\Article\newPage(), MediaWiki\MainConfigNames\UsePostprocCache, MediaWiki\MainConfigNames\UsePostprocCacheLegacy, and MediaWiki\MainConfigNames\UsePostprocCacheParsoid.

Member Function Documentation

◆ addHelpLink()

MediaWiki\Page\Article::addHelpLink ( $to,
$overrideBaseUrl = false )

Adds help link with an icon via page indicators.

Link target can be overridden by a local message containing a wikilink: the message key is: 'namespace-' + namespace number + '-helppage'.

Parameters
string$toTarget MediaWiki.org page title or encoded URL.
bool$overrideBaseUrlWhether $url is a full URL, to avoid MW.o.
Since
1.25

Definition at line 1986 of file Article.php.

Referenced by MediaWiki\Page\CategoryPage\closeShowCategory().

◆ adjustDisplayTitle()

MediaWiki\Page\Article::adjustDisplayTitle ( ParserOutput $pOutput)

Adjust title for pages with displaytitle, -{T|}- or language conversion.

Definition at line 1064 of file Article.php.

References MediaWiki\Parser\ParserOutput\getTitleText().

◆ clear()

MediaWiki\Page\Article::clear ( )

Definition at line 261 of file Article.php.

◆ fetchRevisionRecord()

MediaWiki\Page\Article::fetchRevisionRecord ( )

Fetches the revision to work on.

The revision is loaded from the database. Refer to $this->fetchResult for the revision or any errors encountered while loading it.

Public since 1.35

Returns
RevisionRecord|null

Definition at line 360 of file Article.php.

References wfDebug().

◆ formatRobotPolicy()

static MediaWiki\Page\Article::formatRobotPolicy ( $policy)
static

Converts a String robot policy into an associative array, to allow merging of several policies using array_merge().

Parameters
array | string$policyReturns empty array on null/false/'', transparent to already-converted arrays, converts string.
Returns
array 'index' => \<indexpolicy\>, 'follow' => \<followpolicy\>

Definition at line 1252 of file Article.php.

◆ getActionOverrides()

MediaWiki\Page\Article::getActionOverrides ( )

Call to WikiPage function for backwards compatibility.

See also
ContentHandler::getActionOverrides
Returns
array

Definition at line 2144 of file Article.php.

◆ getContext()

◆ getOldID()

MediaWiki\Page\Article::getOldID ( )
See also
getOldIDFromRequest()
getRevIdFetched()
Returns
int The oldid of the article that is was requested in the constructor or via the context's WebRequest.

Definition at line 279 of file Article.php.

◆ getOldIDFromRequest()

MediaWiki\Page\Article::getOldIDFromRequest ( )

Sets $this->mRedirectUrl to a correct URL if the query parameters are incorrect.

Returns
int The old id for the request

Definition at line 292 of file Article.php.

◆ getPage()

◆ getParserOptions()

MediaWiki\Page\Article::getParserOptions ( )

Get parser options suitable for rendering the primary article wikitext.

Returns
ParserOptions

Definition at line 2107 of file Article.php.

◆ getParserOutput()

MediaWiki\Page\Article::getParserOutput ( $oldid = null,
?UserIdentity $user = null )

Lightweight method to get the parser output for a page, checking the parser cache and so on.

Doesn't consider most of the stuff that Article::view() is forced to consider, so it's not appropriate to use there.

Since
1.16 (r52326) for LiquidThreads
Parameters
int | null$oldidRevision ID or null
UserIdentity | null$userThe relevant user
Returns
ParserOutput|false ParserOutput or false if the given revision ID is not found

Definition at line 2092 of file Article.php.

◆ getRedirectedFrom()

MediaWiki\Page\Article::getRedirectedFrom ( )

Get the page this view was redirected from.

Returns
Title|null
Since
1.28

Definition at line 230 of file Article.php.

◆ getRevIdFetched()

MediaWiki\Page\Article::getRevIdFetched ( )

Use this to fetch the rev ID used on page views.

Before fetchRevisionRecord was called, this returns the page's latest revision, regardless of what getOldID() returns.

Returns
int Revision ID of last article revision

Definition at line 437 of file Article.php.

◆ getRobotPolicy()

MediaWiki\Page\Article::getRobotPolicy ( $action,
?ParserOutput $pOutput = null )

Get the robot policy to be used for the current view.

Parameters
string$actionThe action= GET parameter
ParserOutput | null$pOutput
Returns
string[] The policy that should be set
Todo
actions other than 'view'

Definition at line 1169 of file Article.php.

References NS_USER, and NS_USER_TALK.

◆ getTitle()

MediaWiki\Page\Article::getTitle ( )

◆ isCurrent()

MediaWiki\Page\Article::isCurrent ( )

Returns true if the currently-referenced revision is the current edit to this page (and it exists).

Returns
bool

Definition at line 418 of file Article.php.

◆ isDiffOnlyView()

MediaWiki\Page\Article::isDiffOnlyView ( )
protected

◆ isFileCacheable()

MediaWiki\Page\Article::isFileCacheable ( $mode = HTMLFileCache::MODE_NORMAL)

Check if the page can be cached.

Parameters
int$modeOne of the HTMLFileCache::MODE_* constants (since 1.28)
Returns
bool

Definition at line 2066 of file Article.php.

◆ newFromID()

static MediaWiki\Page\Article::newFromID ( $id)
static

Constructor from a page id.

Parameters
int$idArticle ID to load

Definition at line 180 of file Article.php.

◆ newFromTitle()

static MediaWiki\Page\Article::newFromTitle ( $title,
IContextSource $context )
static

Create an Article object of the appropriate class for the given page.

Parameters
Title$title
IContextSource$context

Definition at line 191 of file Article.php.

References MediaWiki\Deferred\LinksUpdate\CategoryLinksTable\makeTitle(), and NS_FILE.

◆ newFromWikiPage()

static MediaWiki\Page\Article::newFromWikiPage ( WikiPage $page,
IContextSource $context )
static

Create an Article object of the appropriate class for the given page.

Parameters
WikiPage$page
IContextSource$context
Returns
Article

Definition at line 219 of file Article.php.

References MediaWiki\Page\WikiPage\getTitle().

◆ newPage()

MediaWiki\Page\Article::newPage ( Title $title)
protected
Parameters
Title$title
Returns
WikiPage

Reimplemented in MediaWiki\Page\CategoryPage, and MediaWiki\Page\ImagePage.

Definition at line 172 of file Article.php.

Referenced by MediaWiki\Page\Article\__construct().

◆ protect()

MediaWiki\Page\Article::protect ( )

action=protect handler

Definition at line 2014 of file Article.php.

◆ purgePatrolFooterCache()

static MediaWiki\Page\Article::purgePatrolFooterCache ( $articleID)
static

Purge the cache used to check if it is worth showing the patrol footer For example, it is done during re-uploads when file patrol is used.

Parameters
int$articleIDID of the article to purge
Since
1.27

Definition at line 1585 of file Article.php.

◆ render()

MediaWiki\Page\Article::render ( )

Handle action=render.

Definition at line 2003 of file Article.php.

◆ setContext()

MediaWiki\Page\Article::setContext ( $context)

Sets the context this Article is executed in.

Parameters
IContextSource$context
Since
1.18

Definition at line 2119 of file Article.php.

◆ setOldSubtitle()

MediaWiki\Page\Article::setOldSubtitle ( $oldid = 0)

Generate the navigation links when browsing through an article revisions It shows the information as: Revision as of \<date\>; view current revision \<- Previous version | Next Version -\>

Parameters
int$oldidRevision ID of this article revision

Definition at line 1825 of file Article.php.

References MediaWiki\Output\OutputPage\addModuleStyles(), MediaWiki\Output\OutputPage\addSubtitle(), and MediaWiki\Context\ContextSource\getOutput().

◆ setRedirectedFrom()

MediaWiki\Page\Article::setRedirectedFrom ( Title $from)

Tell the page view functions that this view was redirected from another page on the wiki.

Definition at line 238 of file Article.php.

◆ setUseLegacyPostprocCache()

MediaWiki\Page\Article::setUseLegacyPostprocCache ( bool $val = true)

By default, we do not use the postprocessing cache for legacy parses; however, we want to be able to override this for some cases (e.g.

legacy parses of DiscussionTools, as long as Parsoid Read Views is not the default everywhere.)

Definition at line 2184 of file Article.php.

◆ showDeletedRevisionHeader()

MediaWiki\Page\Article::showDeletedRevisionHeader ( )

If the revision requested for view is deleted, check permissions.

Send either an error message or a warning header to the output.

Returns
bool True if the view is allowed, false if not.

Definition at line 1758 of file Article.php.

◆ showDiffPage()

MediaWiki\Page\Article::showDiffPage ( )
protected

Show a diff page according to current request variables.

For use within Article::view() only, other callers should use the DifferenceEngine class.

Definition at line 1081 of file Article.php.

◆ showMissingArticle()

MediaWiki\Page\Article::showMissingArticle ( )

Show the error text for a missing article.

For articles in the MediaWiki namespace, show the default message text. To be called from Article::view().

Definition at line 1594 of file Article.php.

References NS_MEDIAWIKI, NS_USER, NS_USER_TALK, and wfEscapeWikiText().

◆ showNamespaceHeader()

MediaWiki\Page\Article::showNamespaceHeader ( )

Show a header specific to the namespace currently being viewed, such as [[MediaWiki:Subjectpageheader]] on subject pages or [[MediaWiki:Talkpageheader]] on talk pages.

This function is used in Article::view().

For the addition of subject page headers, see T151682.

Definition at line 1357 of file Article.php.

◆ showPatrolFooter()

MediaWiki\Page\Article::showPatrolFooter ( )

If patrol is possible, output a patrol UI box.

This is called from the footer section of ordinary page views. If patrol is not possible or not desired, does nothing.

Side effect: When the patrol link is build, this method will call OutputPage::setPreventClickjacking(true) and load a JS module.

Returns
bool

Definition at line 1407 of file Article.php.

References NS_FILE, and SCHEMA_COMPAT_READ_OLD.

◆ showProtectionIndicator()

MediaWiki\Page\Article::showProtectionIndicator ( )

Show a lock icon above the article body if the page is protected.

Definition at line 609 of file Article.php.

◆ showRedirectedFromHeader()

MediaWiki\Page\Article::showRedirectedFromHeader ( )

If this request is a redirect view, send "redirected from" subtitle to the output.

Returns true if the header was needed, false if this is not a redirect view. Handles both local and remote redirects.

Returns
bool

Definition at line 1279 of file Article.php.

◆ showViewFooter()

MediaWiki\Page\Article::showViewFooter ( )

Show the footer section of an ordinary page view.

Definition at line 1383 of file Article.php.

References NS_USER_TALK.

◆ tryFileCache()

MediaWiki\Page\Article::tryFileCache ( )
protected

checkLastModified returns true if it has taken care of all output to the client that is necessary for this request.

(that is, it has sent a cached version of the page)

Returns
bool True if cached version send, false otherwise

Definition at line 2035 of file Article.php.

References wfDebug().

◆ unprotect()

MediaWiki\Page\Article::unprotect ( )

action=unprotect handler (alias)

Definition at line 2022 of file Article.php.

◆ view()

MediaWiki\Page\Article::view ( )

This is the default action of the index.php entry point: just view the page of the given title.

Reimplemented in MediaWiki\Page\CategoryPage, and MediaWiki\Page\ImagePage.

Definition at line 451 of file Article.php.

References wfDebug(), and wfMessage().

Member Data Documentation

◆ $blockStore

DatabaseBlockStore MediaWiki\Page\Article::$blockStore
protected

Definition at line 121 of file Article.php.

◆ $dbProvider

IConnectionProvider MediaWiki\Page\Article::$dbProvider
protected

Definition at line 120 of file Article.php.

◆ $linkRenderer

LinkRenderer MediaWiki\Page\Article::$linkRenderer
protected

Definition at line 111 of file Article.php.

◆ $mOldId

int null MediaWiki\Page\Article::$mOldId

The oldid of the article that was requested to be shown, 0 for the current revision.

Definition at line 83 of file Article.php.

◆ $mPage

WikiPage MediaWiki\Page\Article::$mPage
protected

The WikiPage object of this instance.

Definition at line 77 of file Article.php.

◆ $mParserOutput

ParserOutput null false MediaWiki\Page\Article::$mParserOutput = null

The ParserOutput generated for viewing the page, initialized by view().

If no ParserOutput could be generated, this is set to false.

Deprecated
since 1.32

Definition at line 102 of file Article.php.

◆ $mRedirectedFrom

Title null MediaWiki\Page\Article::$mRedirectedFrom = null

Title from which we were redirected here, if any.

Definition at line 86 of file Article.php.

◆ $mRedirectUrl

string false MediaWiki\Page\Article::$mRedirectUrl = false

URL to redirect to or false if none.

Definition at line 89 of file Article.php.

◆ $restrictionStore

RestrictionStore MediaWiki\Page\Article::$restrictionStore
protected

Definition at line 122 of file Article.php.

◆ $viewIsRenderAction

bool MediaWiki\Page\Article::$viewIsRenderAction = false
protected

Whether render() was called.

With the way subclasses work here, there doesn't seem to be any other way to stop calling OutputPage::enableSectionEditLinks() and still have it work as it did before.

Definition at line 109 of file Article.php.


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