MediaWiki REL1_41
WikiPage Class Reference

Base representation for an editable wiki page. More...

Inherits Page, IDBAccessObject, and MediaWiki\Page\PageRecord.

Inherited by WikiCategoryPage, and WikiFilePage.

Collaboration diagram for WikiPage:

Public Member Functions

 __clone ()
 Makes sure that the mTitle object is cloned to the newly cloned WikiPage.
 
 __construct (PageIdentity $pageIdentity)
 
 __toString ()
 Returns an informative human readable unique representation of the page identity, for use as a cache key and for logging and debugging.
Returns
string

 
 __wakeup ()
 Ensure consistency when unserializing.
 
 canExist ()
 
 checkFlags ( $flags)
 Check flags and add EDIT_NEW or EDIT_UPDATE to them as needed.
 
 checkTouched ()
 Loads page_touched and returns a value indicating if it should be used.
 
 clear ()
 Clear the object.
 
 clearPreparedEdit ()
 Clear the mPreparedEdit cache field, as may be needed by mutable content types.
 
 doDeleteArticleBatched ( $reason, $suppress, UserIdentity $deleter, $tags, $logsubtype, $immediate=false, $webRequestId=null)
 Back-end article deletion.
 
 doDeleteArticleReal ( $reason, UserIdentity $deleter, $suppress=false, $u1=null, &$error='', $u2=null, $tags=[], $logsubtype='delete', $immediate=false)
 Back-end article deletion Deletes the article with database consistency, writes logs, purges caches.
 
 doEditUpdates (RevisionRecord $revisionRecord, UserIdentity $user, array $options=[])
 Do standard deferred updates after page edit.
 
 doPurge ()
 Perform the actions of a page purging.
 
 doSecondaryDataUpdates (array $options=[])
 Do secondary data updates (such as updating link tables).
 
 doUpdateRestrictions (array $limit, array $expiry, &$cascade, $reason, UserIdentity $user, $tags=[])
 Update the article's restriction field, and leave a log entry.
 
 doUserEditContent (Content $content, Authority $performer, $summary, $flags=0, $originalRevId=false, $tags=[], $undidRevId=0)
 Change an existing article or create a new article.
 
 doViewUpdates (Authority $performer, $oldid=0, RevisionRecord $oldRev=null)
 Do standard deferred updates after page view (existing or missing page)
 
 exists ()
 
 followRedirect ()
 Get the Title object or URL this page redirects to.
 
 getActionOverrides ()
 
 getAutoDeleteReason (&$hasHistory=false)
 Auto-generates a deletion reason.
 
 getCategories ()
 Returns a list of categories this page is a member of.
 
 getComment ( $audience=RevisionRecord::FOR_PUBLIC, Authority $performer=null)
 
 getContent ( $audience=RevisionRecord::FOR_PUBLIC, Authority $performer=null)
 Get the content of the current revision.
 
 getContentHandler ()
 Returns the ContentHandler instance to be used to deal with the content of this WikiPage.
 
 getContentModel ()
 Returns the page's content model id (see the CONTENT_MODEL_XXX constants).
 
 getContributors ()
 Get a list of users who have edited this article, not including the user who made the most recent revision, which you can get from $article->getUser() if you want it.
 
 getCreator ( $audience=RevisionRecord::FOR_PUBLIC, Authority $performer=null)
 Get the User object of the user who created the page.
 
 getCurrentUpdate ()
 Get the state of an ongoing update, shortly before or just after it is saved to the database.
 
 getDBkey ()
 Get the page title in DB key form.This should always return a valid DB key.
Returns
string

 
 getHiddenCategories ()
 Returns a list of hidden categories this page is a member of.
 
 getId ( $wikiId=self::LOCAL)
 
 getLanguage ()
 
 getLatest ( $wikiId=self::LOCAL)
 Get the page_latest field.
 
 getLinksTimestamp ()
 Get the page_links_updated field.
 
 getMinorEdit ()
 Returns true if last revision was marked as "minor edit".
 
 getNamespace ()
 Returns the page's namespace number.The value returned by this method should represent a valid namespace, but this cannot be guaranteed in all cases.
Returns
int

 
 getPageIsRedirectField ()
 Get the value of the page_is_redirect field in the DB.
 
 getParserOutput (?ParserOptions $parserOptions=null, $oldid=null, $noCache=false)
 Get a ParserOutput for the given ParserOptions and revision ID.
 
 getRedirectTarget ()
 If this page is a redirect, get its target.
 
 getRedirectURL ( $rt)
 Get the Title object or URL to use for a redirect.
 
 getRevisionRecord ()
 Get the latest revision.
 
 getSourceURL ()
 Get the source URL for the content on this page, typically the canonical URL, but may be a remote link if the content comes from another site.
 
 getTimestamp ()
 
 getTitle ()
 Get the title object of the article.
 
 getTouched ()
 Get the page_touched field.
 
 getUser ( $audience=RevisionRecord::FOR_PUBLIC, Authority $performer=null)
 
 getUserText ( $audience=RevisionRecord::FOR_PUBLIC, Authority $performer=null)
 
 getWikiDisplayName ()
 The display name for the site this content come from.
 
 getWikiId ()
 
 hasViewableContent ()
 Check if this page is something we're going to be showing some sort of sensible content for.
 
 insertNullProtectionRevision (string $revCommentMsg, array $limit, array $expiry, bool $cascade, string $reason, UserIdentity $user)
 Insert a new null revision for this page.
 
 insertOn ( $dbw, $pageId=null)
 Insert a new empty page record for this article.
 
 insertRedirect ()
 Insert an entry for this page into the redirect table if the content is a redirect.
 
 insertRedirectEntry (LinkTarget $rt, $oldLatest=null)
 Insert or update the redirect table entry for this page to indicate it redirects to $rt.
 
 isBatchedDelete ( $safetyMargin=0)
 Determines if deletion of this page would be batched (executed over time by the job queue) or not (completed in the same request as the delete call).
 
 isCountable ( $editInfo=false)
 Determine whether a page would be suitable for being counted as an article in the site_stats table based on the title & its content.
 
 isLocal ()
 Whether this content displayed on this page comes from the local database.
 
 isNew ()
 Tests if the page is new (only has one revision).
 
 isRedirect ()
 Is the page a redirect, according to secondary tracking tables? If this is true, getRedirectTarget() will return a Title.
 
 isSamePageAs (PageReference $other)
 Checks whether the given PageReference refers to the same page as this PageReference.Two PageReference instances are considered to refer to the same page if they belong to the same wiki, and have the same namespace and DB key.
Parameters
PageReference$other
Returns
bool

 
 loadFromRow ( $data, $from)
 Load the object from a database row.
 
 loadPageData ( $from='fromdb')
 Load the object from a given source by title.
 
 lockAndGetLatest ()
 Lock the page row for this title+id and return page_latest (or 0)
 
 makeParserOptions ( $context)
 Get parser options suitable for rendering the primary article wikitext.
 
 newPageUpdater ( $performer, RevisionSlotsUpdate $forUpdate=null)
 Returns a PageUpdater for creating new revisions on this page (or creating the page).
 
 pageDataFromId ( $dbr, $id, $options=[])
 Fetch a page record matching the requested ID.
 
 pageDataFromTitle ( $dbr, $title, $options=[])
 Fetch a page record matching the Title object's namespace and title using a sanitized title string.
 
 prepareContentForEdit (Content $content, ?RevisionRecord $revision, UserIdentity $user, $serialFormat=null, $useStash=true)
 Prepare content which is about to be saved.
 
 protectDescription (array $limit, array $expiry)
 Builds the description to serve as comment for the edit.
 
 protectDescriptionLog (array $limit, array $expiry)
 Builds the description to serve as comment for the log entry.
 
 replaceSectionAtRev ( $sectionId, Content $sectionContent, $sectionTitle='', $baseRevId=null)
 
 replaceSectionContent ( $sectionId, Content $sectionContent, $sectionTitle='', $edittime=null)
 
 setTimestamp ( $ts)
 Set the page timestamp (use only to avoid DB queries)
 
 shouldCheckParserCache (ParserOptions $parserOptions, $oldId)
 Should the parser cache be used?
 
 supportsSections ()
 Returns true if this page's content model supports sections.
 
 toPageRecord ()
 Returns the page represented by this WikiPage as a PageStoreRecord.
 
 triggerOpportunisticLinksUpdate (ParserOutput $parserOutput)
 Opportunistically enqueue link update jobs after a fresh parser output was generated.
 
 updateCategoryCounts (array $added, array $deleted, $id=0)
 Update all the appropriate counts in the category table, given that we've added the categories $added and deleted the categories $deleted.
 
 updateParserCache (array $options=[])
 Update the parser cache.
 
 updateRevisionOn ( $dbw, RevisionRecord $revision, $lastRevision=null, $lastRevIsRedirect=null)
 Update the page record to point to a newly saved revision.
 
 wasLoadedFrom ( $from)
 Checks whether the page data was loaded using the given database access mode (or better).
 
- 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 convertSelectType ( $type)
 Convert 'fromdb', 'fromdbmaster' and 'forupdate' to READ_* constants.
 
static getQueryInfo ()
 Return the tables, fields, and join conditions to be selected to create a new page object.
 
static hasDifferencesOutsideMainSlot (RevisionRecord $a, RevisionRecord $b)
 Helper method for checking whether two revisions have differences that go beyond the main slot.
 
static makeParserOptionsFromTitleAndModel (PageReference $pageRef, string $contentModel, $context)
 Create canonical parser options for a given title and content model.
 
static onArticleCreate (Title $title, $maybeIsRedirect=true)
 The onArticle*() functions are supposed to be a kind of hooks which should be called whenever any of the specified actions are done.
 
static onArticleDelete (Title $title)
 Clears caches when article is deleted.
 
static onArticleEdit (Title $title, RevisionRecord $revRecord=null, $slotsChanged=null, $maybeRedirectChanged=true)
 Purge caches on page update etc.
 

Protected Member Functions

 clearCacheFields ()
 Clear the object cache fields.
 
 formatExpiry ( $expiry)
 
 loadLastEdit ()
 Loads everything except the text This isn't necessary for all uses, so it's only done if needed.
 
 pageData ( $dbr, $conditions, $options=[])
 Fetch a page record with the given conditions.
 

Protected Attributes

bool $mDataLoaded = false
 
int $mDataLoadedFrom = self::READ_NONE
 One of the READ_* constants.
 
int null $mId = null
 
string null $mLanguage = null
 
int false $mLatest = false
 False means "not loaded".
 
string $mLinksUpdated = '19700101000000'
 
PreparedEdit false $mPreparedEdit = false
 Map of cache fields (text, parser output, ect) for a proposed/new edit.
 
Title null $mRedirectTarget = null
 The cache of the redirect target.
 
string $mTimestamp = ''
 Timestamp of the current revision or empty string if not loaded.
 
Title $mTitle
 
string $mTouched = '19700101000000'
 

Additional Inherited Members

- Public Attributes inherited from IDBAccessObject
const READ_NONE = -1
 Constants for object loading bitfield flags (higher => higher QoS)
 

Detailed Description

Base representation for an editable wiki page.

Some fields are public only for backwards-compatibility. Use accessor methods. In the past, this class was part of Article.php and everything was public.

Definition at line 77 of file WikiPage.php.

Constructor & Destructor Documentation

◆ __construct()

WikiPage::__construct ( PageIdentity $pageIdentity)
Parameters
PageIdentity$pageIdentity

Definition at line 169 of file WikiPage.php.

References MediaWiki\DAO\WikiAwareEntity\assertWiki().

Member Function Documentation

◆ __clone()

WikiPage::__clone ( )

Makes sure that the mTitle object is cloned to the newly cloned WikiPage.

Definition at line 185 of file WikiPage.php.

References $mTitle.

◆ __toString()

WikiPage::__toString ( )

Returns an informative human readable unique representation of the page identity, for use as a cache key and for logging and debugging.

Returns
string

Since
1.36

Implements MediaWiki\Page\PageReference.

Definition at line 3201 of file WikiPage.php.

◆ __wakeup()

WikiPage::__wakeup ( )

Ensure consistency when unserializing.

Note
WikiPage objects should never be serialized in the first place. But some extensions like AbuseFilter did (see T213006), and we need to be able to read old data (see T187153).

Definition at line 3156 of file WikiPage.php.

◆ canExist()

WikiPage::canExist ( )
Returns
true
Since
1.36

Implements MediaWiki\Page\ProperPageIdentity.

Definition at line 3193 of file WikiPage.php.

◆ checkFlags()

WikiPage::checkFlags ( $flags)

Check flags and add EDIT_NEW or EDIT_UPDATE to them as needed.

Deprecated
since 1.32, use exists() instead, or simply omit the EDIT_UPDATE and EDIT_NEW flags. To protect against race conditions, use PageUpdater::grabParentRevision.
Parameters
int$flags
Returns
int Updated $flags

Definition at line 1630 of file WikiPage.php.

References EDIT_NEW, and EDIT_UPDATE.

◆ checkTouched()

WikiPage::checkTouched ( )

Loads page_touched and returns a value indicating if it should be used.

Returns
bool True if this page exists and is not a redirect

Definition at line 652 of file WikiPage.php.

◆ clear()

WikiPage::clear ( )

Clear the object.

Returns
void

Definition at line 266 of file WikiPage.php.

◆ clearCacheFields()

WikiPage::clearCacheFields ( )
protected

Clear the object cache fields.

Returns
void

Definition at line 277 of file WikiPage.php.

◆ clearPreparedEdit()

WikiPage::clearPreparedEdit ( )

Clear the mPreparedEdit cache field, as may be needed by mutable content types.

Returns
void
Since
1.23

Definition at line 299 of file WikiPage.php.

◆ convertSelectType()

static WikiPage::convertSelectType ( $type)
static

Convert 'fromdb', 'fromdbmaster' and 'forupdate' to READ_* constants.

Parameters
stdClass | string | int$type
Returns
mixed

Definition at line 195 of file WikiPage.php.

◆ doDeleteArticleBatched()

WikiPage::doDeleteArticleBatched ( $reason,
$suppress,
UserIdentity $deleter,
$tags,
$logsubtype,
$immediate = false,
$webRequestId = null )

Back-end article deletion.

Only invokes batching via the job queue if necessary per $wgDeleteRevisionsBatchSize. Deletions can often be completed inline without involving the job queue.

Potentially called many times per deletion operation for pages with many revisions.

Deprecated
since 1.37 No external caller besides DeletePageJob should use this.
Parameters
string$reason
bool$suppress
UserIdentity$deleter
string[]$tags
string$logsubtype
bool$immediate
string | null$webRequestId
Returns
Status

Definition at line 2633 of file WikiPage.php.

References getTitle(), wfDeprecated(), and wfEscapeWikiText().

◆ doDeleteArticleReal()

WikiPage::doDeleteArticleReal ( $reason,
UserIdentity $deleter,
$suppress = false,
$u1 = null,
& $error = '',
$u2 = null,
$tags = [],
$logsubtype = 'delete',
$immediate = false )

Back-end article deletion Deletes the article with database consistency, writes logs, purges caches.

Since
1.19
1.35 Signature changed, user moved to second parameter to prepare for requiring a user to be passed
1.36 User second parameter is required
Deprecated
since 1.37 Use DeletePage instead. Calling ::deleteIfAllowed and letting DeletePage handle permission checks is preferred over doing permission checks yourself and then calling ::deleteUnsafe. Note that DeletePage returns a good status with false value in case of scheduled deletion, instead of a status with a warning. Also, the new method doesn't have an $error parameter, since any error is added to the returned Status.
Parameters
string$reasonDelete reason for deletion log
UserIdentity$deleterThe deleting user
bool$suppressSuppress all revisions and log the deletion in the suppression log instead of the deletion log
bool | null$u1Unused
array | string&$errorArray of errors to append to
mixed$u2Unused
string[] | null$tagsTags to apply to the deletion action
string$logsubtype
bool$immediatefalse allows deleting over time via the job queue
Returns
Status Status object; if successful, $status->value is the log_id of the deletion log entry. If the page couldn't be deleted because it wasn't found, $status is a non-fatal 'cannotdelete' error

Definition at line 2586 of file WikiPage.php.

References getTitle(), and wfEscapeWikiText().

◆ doEditUpdates()

WikiPage::doEditUpdates ( RevisionRecord $revisionRecord,
UserIdentity $user,
array $options = [] )

Do standard deferred updates after page edit.

Update links tables, site stats, search index and message cache. Purges pages that include this page if the text was changed here. Every 100th edit, prune the recent changes table.

Deprecated
since 1.32 (soft), use DerivedPageDataUpdater::doUpdates instead.
Parameters
RevisionRecord$revisionRecord(Switched from the old Revision class to RevisionRecord since 1.35)
UserIdentity$userUser object that did the revision
array$optionsArray of options, following indexes are used:
  • changed: bool, whether the revision changed the content (default true)
  • created: bool, whether the revision created the page (default false)
  • moved: bool, whether the page was moved (default false)
  • restored: bool, whether the page was undeleted (default false)
  • oldrevision: RevisionRecord object for the pre-update revision (default null)
  • oldcountable: bool, null, or string 'no-change' (default null):
    • bool: whether the page was counted as an article before that revision, only used in changed is true and created is false
    • null: if created is false, don't update the article count; if created is true, do update the article count
    • 'no-change': don't update the article count, ever
  • causeAction: an arbitrary string identifying the reason for the update. See DataUpdate::getCauseAction(). (default 'edit-page')
  • causeAgent: name of the user who caused the update. See DataUpdate::getCauseAgent(). (string, defaults to the passed user)

Definition at line 2004 of file WikiPage.php.

References MediaWiki\User\UserIdentity\getName().

◆ doPurge()

WikiPage::doPurge ( )

Perform the actions of a page purging.

Returns
bool
Note
In 1.28 (and only 1.28), this took a $flags parameter that controlled how much purging was done.

Reimplemented in WikiCategoryPage, and WikiFilePage.

Definition at line 1311 of file WikiPage.php.

References NS_MEDIAWIKI.

◆ doSecondaryDataUpdates()

WikiPage::doSecondaryDataUpdates ( array $options = [])

Do secondary data updates (such as updating link tables).

Secondary data updates are only a small part of the updates needed after saving a new revision; normally PageUpdater::doUpdates should be used instead (which includes secondary data updates). This method is provided for partial purges.

Note
This does not update the parser cache. Use updateParserCache() for that.
Parameters
array$options
  • recursive (bool, default true): whether to do a recursive update (update pages that depend on this page, e.g. transclude it). This will set the $recursive parameter of Content::getSecondaryDataUpdates. Typically this should be true unless the update was something that did not really change the page, such as a null edit.
  • triggeringUser: The user triggering the update (UserIdentity, defaults to the user who created the revision)
  • causeAction: an arbitrary string identifying the reason for the update. See DataUpdate::getCauseAction(). (default 'unknown')
  • causeAgent: name of the user who caused the update (string, default 'unknown')
  • defer: one of the DeferredUpdates constants, or false to run immediately (default: false). Note that even when this is set to false, some updates might still get deferred (as some update might directly add child updates to DeferredUpdates).
  • known-revision-output: a combined canonical ParserOutput for the revision, perhaps from some cache. The caller is responsible for ensuring that the ParserOutput indeed matched the $rev and $options. This mechanism is intended as a temporary stop-gap, for the time until caches have been changed to store RenderedRevision states instead of ParserOutput objects. (default: null) (since 1.33)
Since
1.32

Definition at line 2076 of file WikiPage.php.

◆ doUpdateRestrictions()

WikiPage::doUpdateRestrictions ( array $limit,
array $expiry,
& $cascade,
$reason,
UserIdentity $user,
$tags = [] )

Update the article's restriction field, and leave a log entry.

This works for protection both existing and non-existing pages.

Parameters
array$limitSet of restriction keys
array$expiryPer restriction type expiration
bool&$cascadeSet to false if cascading protection isn't allowed.
string$reason
UserIdentity$userThe user updating the restrictions
string[]$tagsChange tags to add to the pages and protection log entries ($user should be able to add the specified tags before this is called)
Returns
Status Status object; if action is taken, $status->value is the log_id of the protection log entry.

Definition at line 2106 of file WikiPage.php.

References DB_PRIMARY, MediaWiki\User\UserIdentity\getId(), wfGetDB(), and wfMessage().

◆ doUserEditContent()

WikiPage::doUserEditContent ( Content $content,
Authority $performer,
$summary,
$flags = 0,
$originalRevId = false,
$tags = [],
$undidRevId = 0 )

Change an existing article or create a new article.

Updates RC and all necessary caches, optionally via the deferred update array.

Deprecated
since 1.36, use PageUpdater::saveRevision instead. Note that the new method expects callers to take care of checking EDIT_MINOR against the minoredit right, and to apply the autopatrol right as appropriate.
Parameters
Content$contentNew content
Authority$performerdoing the edit
string | CommentStoreComment$summaryEdit summary
int$flagsBitfield: EDIT_NEW Article is known or assumed to be non-existent, create a new one EDIT_UPDATE Article is known or assumed to be pre-existing, update it EDIT_MINOR Mark this edit minor, if the user is allowed to do so EDIT_SUPPRESS_RC Do not log the change in recentchanges EDIT_FORCE_BOT Mark the edit a "bot" edit regardless of user rights EDIT_AUTOSUMMARY Fill in blank summaries with generated text where possible EDIT_INTERNAL Signal that the page retrieve/save cycle happened entirely in this request.

If neither EDIT_NEW nor EDIT_UPDATE is specified, the status of the article will be detected. If EDIT_UPDATE is specified and the article doesn't exist, the function will return an edit-gone-missing error. If EDIT_NEW is specified and the article does exist, an edit-already-exists error will be returned. These two conditions are also possible with auto-detection due to MediaWiki's performance-optimised locking strategy.

Parameters
int | false$originalRevId,The ID of an original revision that the edit restores or repeats. The new revision is expected to have the exact same content as the given original revision. This is used with rollbacks and with dummy "null" revisions which are created to record things like page moves. Default is false, meaning we are not making a rollback edit.
array | null$tagsChange tags to apply to this edit Callers are responsible for permission checks (with ChangeTags::canAddTagsAccompanyingChange)
int$undidRevIdId of revision that was undone or 0
Returns
PageUpdateStatus Possible errors: edit-hook-aborted: The ArticleSave hook aborted the edit but didn't set the fatal flag of $status. edit-gone-missing: In update mode, but the article didn't exist. edit-conflict: In update mode, the article changed unexpectedly. edit-no-change: Warning that the text was the same as before. edit-already-exists: In creation mode, but the article already exists.

Extensions may define additional errors.

$return->value will contain an associative array with members as follows: new: Boolean indicating if the function attempted to create a new article. revision-record: The revision record object for the inserted revision, or null.

Since
1.36

Definition at line 1806 of file WikiPage.php.

◆ doViewUpdates()

WikiPage::doViewUpdates ( Authority $performer,
$oldid = 0,
RevisionRecord $oldRev = null )

Do standard deferred updates after page view (existing or missing page)

Parameters
Authority$performerThe viewing user
int$oldidRevision id being viewed; if not given or 0, latest revision is assumed
RevisionRecord | null$oldRevThe RevisionRecord associated with $oldid.

Definition at line 1265 of file WikiPage.php.

◆ exists()

WikiPage::exists ( )
Returns
bool Whether or not the page exists in the database

Implements MediaWiki\Page\PageIdentity.

Definition at line 540 of file WikiPage.php.

Referenced by MediaWiki\Deferred\LinksUpdate\LinksDeletionUpdate\__construct(), and MediaWiki\Storage\DerivedPageDataUpdater\getSecondaryDataUpdates().

◆ followRedirect()

WikiPage::followRedirect ( )

Get the Title object or URL this page redirects to.

Returns
bool|Title|string False, Title of in-wiki target, or string with URL

Reimplemented in WikiFilePage.

Definition at line 1108 of file WikiPage.php.

◆ formatExpiry()

WikiPage::formatExpiry ( $expiry)
protected
Parameters
string$expiry14-char timestamp or "infinity", or false if the input was invalid
Returns
string

Definition at line 2455 of file WikiPage.php.

References wfMessage().

◆ getActionOverrides()

WikiPage::getActionOverrides ( )
Todo
Move this UI stuff somewhere else
See also
ContentHandler::getActionOverrides
Returns
array

Reimplemented in WikiFilePage.

Definition at line 236 of file WikiPage.php.

◆ getAutoDeleteReason()

WikiPage::getAutoDeleteReason ( & $hasHistory = false)

Auto-generates a deletion reason.

Parameters
bool&$hasHistoryWhether the page has a history
Returns
string|false String containing deletion reason or empty string, or boolean false if no revision occurred

Definition at line 2942 of file WikiPage.php.

References getTitle(), and wfDeprecated().

◆ getCategories()

WikiPage::getCategories ( )

Returns a list of categories this page is a member of.

Results will include hidden categories

Returns
TitleArrayFromResult

Definition at line 2888 of file WikiPage.php.

References DB_REPLICA, NS_CATEGORY, and wfGetDB().

◆ getComment()

WikiPage::getComment ( $audience = RevisionRecord::FOR_PUBLIC,
Authority $performer = null )
Parameters
int$audienceOne of: RevisionRecord::FOR_PUBLIC to be displayed to all users RevisionRecord::FOR_THIS_USER to be displayed to the given user RevisionRecord::RAW get the text regardless of permissions
Authority | null$performerobject to check for, only if FOR_THIS_USER is passed to the $audience parameter (since 1.36, if using FOR_THIS_USER and not specifying a user no fallback is provided and the RevisionRecord method will throw an error)
Returns
string|null Comment stored for the last article revision, or null if the specified audience does not have access to the comment.

Definition at line 876 of file WikiPage.php.

◆ getContent()

WikiPage::getContent ( $audience = RevisionRecord::FOR_PUBLIC,
Authority $performer = null )

Get the content of the current revision.

No side-effects...

Parameters
int$audienceOne of: RevisionRecord::FOR_PUBLIC to be displayed to all users RevisionRecord::FOR_THIS_USER to be displayed to the given user RevisionRecord::RAW get the text regardless of permissions
Authority | null$performerobject to check for, only if FOR_THIS_USER is passed to the $audience parameter
Returns
Content|null The content of the current revision
Since
1.21

Definition at line 776 of file WikiPage.php.

Referenced by TextContentHandler\getDataForSearchIndex().

◆ getContentHandler()

WikiPage::getContentHandler ( )

Returns the ContentHandler instance to be used to deal with the content of this WikiPage.

Shorthand for ContentHandler::getForModelID( $this->getContentModel() );

Returns
ContentHandler
Since
1.21

Definition at line 249 of file WikiPage.php.

◆ getContentModel()

WikiPage::getContentModel ( )

Returns the page's content model id (see the CONTENT_MODEL_XXX constants).

Will use the revisions actual content model if the page exists, and the page's default if the page doesn't exist yet.

Returns
string
Since
1.21

Definition at line 613 of file WikiPage.php.

◆ getContributors()

WikiPage::getContributors ( )

Get a list of users who have edited this article, not including the user who made the most recent revision, which you can get from $article->getUser() if you want it.

Returns
UserArrayFromResult

Definition at line 1160 of file WikiPage.php.

References DB_REPLICA, getUser(), and wfGetDB().

◆ getCreator()

WikiPage::getCreator ( $audience = RevisionRecord::FOR_PUBLIC,
Authority $performer = null )

Get the User object of the user who created the page.

Parameters
int$audienceOne of: RevisionRecord::FOR_PUBLIC to be displayed to all users RevisionRecord::FOR_THIS_USER to be displayed to the given user RevisionRecord::RAW get the text regardless of permissions
Authority | null$performerobject to check for, only if FOR_THIS_USER is passed to the $audience parameter (since 1.36, if using FOR_THIS_USER and not specifying a user no fallback is provided and the RevisionRecord method will throw an error)
Returns
UserIdentity|null

Definition at line 836 of file WikiPage.php.

References getTitle(), and MediaWiki\Revision\RevisionRecord\getUser().

◆ getCurrentUpdate()

WikiPage::getCurrentUpdate ( )

Get the state of an ongoing update, shortly before or just after it is saved to the database.

If there is no ongoing edit tracked by this WikiPage instance, this methods throws a PreconditionException.

If possible, state is shared with subsequent calls of getPreparedUpdate(), prepareContentForEdit(), and newPageUpdater().

Note
This method should generally be avoided, since it forces WikiPage to maintain state representing ongoing edits. Code that initiates an edit should use newPageUpdater() instead. Hooks that interact with the edit should have a the relevant information provided as a PageUpdater, PreparedUpdate, or RenderedRevision.
Exceptions
PreconditionExceptionif there is no ongoing update. This method must only be called after newPageUpdater() had already been called, typically while executing a handler for a hook that is triggered during a page edit.
Returns
PreparedUpdate
Since
1.38

Definition at line 2373 of file WikiPage.php.

◆ getDBkey()

WikiPage::getDBkey ( )

Get the page title in DB key form.This should always return a valid DB key.

Returns
string

Since
1.36

Implements MediaWiki\Page\ProperPageIdentity.

Definition at line 3177 of file WikiPage.php.

◆ getHiddenCategories()

WikiPage::getHiddenCategories ( )

Returns a list of hidden categories this page is a member of.

Uses the page_props and categorylinks tables.

Returns
Title[]

Definition at line 2910 of file WikiPage.php.

References DB_REPLICA, NS_CATEGORY, and wfGetDB().

◆ getId()

WikiPage::getId ( $wikiId = self::LOCAL)

◆ getLanguage()

WikiPage::getLanguage ( )
Returns
?string language code for the page

Implements MediaWiki\Page\PageRecord.

Definition at line 670 of file WikiPage.php.

◆ getLatest()

WikiPage::getLatest ( $wikiId = self::LOCAL)

Get the page_latest field.

Parameters
string | false$wikiId
Returns
int The rev_id of current revision

Implements MediaWiki\Page\PageRecord.

Definition at line 694 of file WikiPage.php.

◆ getLinksTimestamp()

WikiPage::getLinksTimestamp ( )

Get the page_links_updated field.

Returns
string|null Timestamp in TS_MW format

Definition at line 682 of file WikiPage.php.

◆ getMinorEdit()

WikiPage::getMinorEdit ( )

Returns true if last revision was marked as "minor edit".

Returns
bool Minor edit indicator for the last article revision.

Definition at line 891 of file WikiPage.php.

◆ getNamespace()

WikiPage::getNamespace ( )

Returns the page's namespace number.The value returned by this method should represent a valid namespace, but this cannot be guaranteed in all cases.

Returns
int

Since
1.36

Implements MediaWiki\Page\PageReference.

Definition at line 3169 of file WikiPage.php.

◆ getPageIsRedirectField()

WikiPage::getPageIsRedirectField ( )

Get the value of the page_is_redirect field in the DB.

This is probably not what you want. Use WikiPage::isRedirect() to test if the page is a redirect. Use Title::isRedirect() for a fast check for the purposes of linking to a page.

Deprecated
since 1.41
Since
1.36
Returns
bool

Definition at line 579 of file WikiPage.php.

References wfDeprecated().

◆ getParserOutput()

WikiPage::getParserOutput ( ?ParserOptions $parserOptions = null,
$oldid = null,
$noCache = false )

Get a ParserOutput for the given ParserOptions and revision ID.

The parser cache will be used if possible. Cache misses that result in parser runs are debounced with PoolCounter.

XXX merge this with updateParserCache()?

Since
1.19
Parameters
ParserOptions | null$parserOptionsParserOptions to use for the parse operation
null | int$oldidRevision ID to get the text from, passing null or 0 will get the current revision (default value)
bool$noCacheDo not read from or write to caches.
Returns
ParserOutput|false ParserOutput or false if the revision was not found or is not public

Definition at line 1234 of file WikiPage.php.

References getTitle().

◆ getQueryInfo()

static WikiPage::getQueryInfo ( )
static

Return the tables, fields, and join conditions to be selected to create a new page object.

Since
1.31
Returns
array[] With three keys:
  • tables: (string[]) to include in the $table to IReadableDatabase->select() or SelectQueryBuilder::tables
  • fields: (string[]) to include in the $vars to IReadableDatabase->select() or SelectQueryBuilder::fields
  • joins: (array) to include in the $join_conds to IReadableDatabase->select() or SelectQueryBuilder::joinConds

Definition at line 316 of file WikiPage.php.

◆ getRedirectTarget()

WikiPage::getRedirectTarget ( )

If this page is a redirect, get its target.

The target will be fetched from the redirect table if possible.

Deprecated
since 1.38 Use RedirectLookup::getRedirectTarget() instead.
Returns
Title|null Title object, or null if this page is not a redirect

Reimplemented in WikiFilePage.

Definition at line 972 of file WikiPage.php.

References DB_REPLICA, NS_FILE, NS_MEDIA, and wfGetDB().

◆ getRedirectURL()

WikiPage::getRedirectURL ( $rt)

Get the Title object or URL to use for a redirect.

We use Title objects for same-wiki, non-special redirects and URLs for everything else.

Parameters
Title$rtRedirect target
Returns
Title|string|false False, Title object of local target, or string with URL

Definition at line 1119 of file WikiPage.php.

References $source.

◆ getRevisionRecord()

WikiPage::getRevisionRecord ( )

Get the latest revision.

Since
1.32
Returns
RevisionRecord|null

Definition at line 758 of file WikiPage.php.

Referenced by ContentHandler\getDataForSearchIndex(), MediaWiki\Storage\DerivedPageDataUpdater\grabCurrentRevision(), and ContentHandler\latestRevision().

◆ getSourceURL()

WikiPage::getSourceURL ( )

Get the source URL for the content on this page, typically the canonical URL, but may be a remote link if the content comes from another site.

Since
1.28
Returns
string

Reimplemented in WikiFilePage.

Definition at line 3146 of file WikiPage.php.

References getTitle().

◆ getTimestamp()

WikiPage::getTimestamp ( )
Returns
string MW timestamp of last article revision

Definition at line 787 of file WikiPage.php.

◆ getTitle()

◆ getTouched()

WikiPage::getTouched ( )

Get the page_touched field.

Returns
string Timestamp in TS_MW format

Implements MediaWiki\Page\PageRecord.

Definition at line 660 of file WikiPage.php.

◆ getUser()

WikiPage::getUser ( $audience = RevisionRecord::FOR_PUBLIC,
Authority $performer = null )
Parameters
int$audienceOne of: RevisionRecord::FOR_PUBLIC to be displayed to all users RevisionRecord::FOR_THIS_USER to be displayed to the given user RevisionRecord::RAW get the text regardless of permissions
Authority | null$performerobject to check for, only if FOR_THIS_USER is passed to the $audience parameter (since 1.36, if using FOR_THIS_USER and not specifying a user no fallback is provided and the RevisionRecord method will throw an error)
Returns
int User ID for the user that made the last article revision

Definition at line 815 of file WikiPage.php.

◆ getUserText()

WikiPage::getUserText ( $audience = RevisionRecord::FOR_PUBLIC,
Authority $performer = null )
Parameters
int$audienceOne of: RevisionRecord::FOR_PUBLIC to be displayed to all users RevisionRecord::FOR_THIS_USER to be displayed to the given user RevisionRecord::RAW get the text regardless of permissions
Authority | null$performerobject to check for, only if FOR_THIS_USER is passed to the $audience parameter (since 1.36, if using FOR_THIS_USER and not specifying a user no fallback is provided and the RevisionRecord method will throw an error)
Returns
string Username of the user that made the last article revision

Definition at line 855 of file WikiPage.php.

◆ getWikiDisplayName()

WikiPage::getWikiDisplayName ( )

The display name for the site this content come from.

If a subclass overrides isLocal(), this could return something other than the current site name

Since
1.28
Returns
string

Reimplemented in WikiFilePage.

Definition at line 3132 of file WikiPage.php.

◆ getWikiId()

WikiPage::getWikiId ( )
Returns
false self::LOCAL
Since
1.36

Implements MediaWiki\Page\ProperPageIdentity.

Definition at line 3185 of file WikiPage.php.

References getTitle().

◆ hasDifferencesOutsideMainSlot()

static WikiPage::hasDifferencesOutsideMainSlot ( RevisionRecord $a,
RevisionRecord $b )
static

Helper method for checking whether two revisions have differences that go beyond the main slot.

MCR migration note: this method should go away!

Deprecated
Use only as a stop-gap before refactoring to support MCR.
Parameters
RevisionRecord$a
RevisionRecord$b
Returns
bool

Definition at line 1511 of file WikiPage.php.

References MediaWiki\Revision\RevisionRecord\getSlots().

◆ hasViewableContent()

WikiPage::hasViewableContent ( )

Check if this page is something we're going to be showing some sort of sensible content for.

If we return false, page views (plain action=view) will return an HTTP 404 response, so spiders and robots can know they're following a bad link.

Returns
bool

Reimplemented in WikiCategoryPage.

Definition at line 555 of file WikiPage.php.

◆ insertNullProtectionRevision()

WikiPage::insertNullProtectionRevision ( string $revCommentMsg,
array $limit,
array $expiry,
bool $cascade,
string $reason,
UserIdentity $user )

Insert a new null revision for this page.

Since
1.35
Parameters
string$revCommentMsgComment message key for the revision
array$limitSet of restriction keys
array$expiryPer restriction type expiration
bool$cascadeSet to false if cascading protection isn't allowed.
string$reason
UserIdentity$userUser to attribute to
Returns
RevisionRecord|null Null on error

Definition at line 2395 of file WikiPage.php.

References wfMessage().

◆ insertOn()

WikiPage::insertOn ( $dbw,
$pageId = null )

Insert a new empty page record for this article.

This must be followed up by creating a revision and running $this->updateRevisionOn( ... ); or else the record will be left in a funky state. Best if all done inside a transaction.

Todo
Factor out into a PageStore service, to be used by PageUpdater.
Parameters
IDatabase$dbw
int | null$pageIdCustom page ID that will be used for the insert statement
Returns
int|false The newly created page_id key; false if the row was not inserted, e.g. because the title already existed or because the specified page ID is already in use.

Definition at line 1347 of file WikiPage.php.

References wfRandom().

◆ insertRedirect()

WikiPage::insertRedirect ( )

Insert an entry for this page into the redirect table if the content is a redirect.

The database update will be deferred via DeferredUpdates

Don't call this function directly unless you know what you're doing.

Deprecated
since 1.41
Returns
Title|null Title object or null if not a redirect

Definition at line 1035 of file WikiPage.php.

References $content, DB_PRIMARY, wfDeprecated(), and wfGetDB().

◆ insertRedirectEntry()

WikiPage::insertRedirectEntry ( LinkTarget $rt,
$oldLatest = null )

Insert or update the redirect table entry for this page to indicate it redirects to $rt.

Parameters
LinkTarget$rtRedirect target
int | null$oldLatestPrior page_latest for check and set
Returns
bool Success

Definition at line 1063 of file WikiPage.php.

References $success, DB_PRIMARY, MediaWiki\Linker\LinkTarget\getDBkey(), MediaWiki\Linker\LinkTarget\getFragment(), MediaWiki\Linker\LinkTarget\getInterwiki(), MediaWiki\Linker\LinkTarget\getNamespace(), and wfGetDB().

◆ isBatchedDelete()

WikiPage::isBatchedDelete ( $safetyMargin = 0)

Determines if deletion of this page would be batched (executed over time by the job queue) or not (completed in the same request as the delete call).

It is unlikely but possible that an edit from another request could push the page over the batching threshold after this function is called, but before the caller acts upon the return value. Callers must decide for themselves how to deal with this. $safetyMargin is provided as an unreliable but situationally useful help for some common cases.

Deprecated
since 1.37 Use DeletePage::isBatchedDelete instead.
Parameters
int$safetyMarginAdded to the revision count when checking for batching
Returns
bool True if deletion would be batched, false otherwise

Definition at line 2547 of file WikiPage.php.

References DB_REPLICA, and wfGetDB().

◆ isCountable()

WikiPage::isCountable ( $editInfo = false)

Determine whether a page would be suitable for being counted as an article in the site_stats table based on the title & its content.

Parameters
PreparedEdit | PreparedUpdate | false$editInfo(false): An object returned by prepareTextForEdit() or getCurrentUpdate() respectively; If false is given, the current database state will be used.
Returns
bool

Definition at line 910 of file WikiPage.php.

References $content, DB_REPLICA, and wfGetDB().

Referenced by MediaWiki\Storage\DerivedPageDataUpdater\grabCurrentRevision().

◆ isLocal()

WikiPage::isLocal ( )

Whether this content displayed on this page comes from the local database.

Since
1.28
Returns
bool

Reimplemented in WikiFilePage.

Definition at line 3119 of file WikiPage.php.

◆ isNew()

WikiPage::isNew ( )

Tests if the page is new (only has one revision).

May produce false negatives for some old pages.

Since
1.36
Returns
bool

Implements MediaWiki\Page\PageRecord.

Definition at line 595 of file WikiPage.php.

◆ isRedirect()

WikiPage::isRedirect ( )

Is the page a redirect, according to secondary tracking tables? If this is true, getRedirectTarget() will return a Title.

Returns
bool

Implements MediaWiki\Page\PageRecord.

Reimplemented in WikiFilePage.

Definition at line 565 of file WikiPage.php.

Referenced by MediaWiki\Storage\DerivedPageDataUpdater\grabCurrentRevision().

◆ isSamePageAs()

WikiPage::isSamePageAs ( PageReference $other)

Checks whether the given PageReference refers to the same page as this PageReference.Two PageReference instances are considered to refer to the same page if they belong to the same wiki, and have the same namespace and DB key.

Parameters
PageReference$other
Returns
bool

Since
1.36
Parameters
PageReference$other
Returns
bool

Implements MediaWiki\Page\PageReference.

Definition at line 3212 of file WikiPage.php.

◆ loadFromRow()

WikiPage::loadFromRow ( $data,
$from )

Load the object from a database row.

Since
1.20
Parameters
stdClass | false$dataDB row containing fields returned by getQueryInfo() or false
string | int$fromOne of the following:
  • "fromdb" or WikiPage::READ_NORMAL if the data comes from a replica DB
  • "fromdbmaster" or WikiPage::READ_LATEST if the data comes from the primary DB
  • "forupdate" or WikiPage::READ_LOCKING if the data comes from the primary DB using SELECT FOR UPDATE

Definition at line 486 of file WikiPage.php.

◆ loadLastEdit()

WikiPage::loadLastEdit ( )
protected

Loads everything except the text This isn't necessary for all uses, so it's only done if needed.

Definition at line 707 of file WikiPage.php.

References getTitle().

◆ loadPageData()

WikiPage::loadPageData ( $from = 'fromdb')

Load the object from a given source by title.

Parameters
stdClass | string | int$fromOne of the following:
  • A DB query result object.
  • "fromdb" or WikiPage::READ_NORMAL to get from a replica DB.
  • "fromdbmaster" or WikiPage::READ_LATEST to get from the primary DB.
  • "forupdate" or WikiPage::READ_LOCKING to get from the primary DB using SELECT FOR UPDATE.
Returns
void

Definition at line 415 of file WikiPage.php.

References DB_REPLICA.

Referenced by MediaWiki\Storage\DerivedPageDataUpdater\getSecondaryDataUpdates(), MediaWiki\Storage\DerivedPageDataUpdater\grabCurrentRevision(), and ContentHandler\latestRevision().

◆ lockAndGetLatest()

WikiPage::lockAndGetLatest ( )

Lock the page row for this title+id and return page_latest (or 0)

Returns
int Returns 0 if no row was found with this title+id
Since
1.27

Definition at line 2667 of file WikiPage.php.

References DB_PRIMARY, getTitle(), and wfGetDB().

◆ makeParserOptions()

WikiPage::makeParserOptions ( $context)

Get parser options suitable for rendering the primary article wikitext.

See also
ParserOptions::newCanonical
Parameters
IContextSource | UserIdentity | string$contextOne of the following:
  • IContextSource: Use the User and the Language of the provided context
  • UserIdentity: Use the provided UserIdentity object and $wgLang for the language, so use an IContextSource object if possible.
  • 'canonical': Canonical options (anonymous user with default preferences and content language).
Returns
ParserOptions

Definition at line 1890 of file WikiPage.php.

References getTitle().

Referenced by ContentHandler\getParserOutputForIndexing().

◆ makeParserOptionsFromTitleAndModel()

static WikiPage::makeParserOptionsFromTitleAndModel ( PageReference $pageRef,
string $contentModel,
$context )
static

Create canonical parser options for a given title and content model.

Access: internal
Parameters
PageReference$pageRef
string$contentModel
IContextSource | UserIdentity | string$contextSee ::makeParserOptions
Returns
ParserOptions

Definition at line 1904 of file WikiPage.php.

References CONTENT_MODEL_WIKITEXT.

◆ newPageUpdater()

WikiPage::newPageUpdater ( $performer,
RevisionSlotsUpdate $forUpdate = null )

Returns a PageUpdater for creating new revisions on this page (or creating the page).

The PageUpdater can also be used to detect the need for edit conflict resolution, and to protected such conflict resolution from concurrent edits using a check-and-set mechanism.

Since
1.32
Note
Once extensions no longer rely on WikiPage to get access to the state of an ongoing edit via prepareContentForEdit() and WikiPage::getCurrentUpdate(), this method should be deprecated and callers should be migrated to using PageUpdaterFactory::newPageUpdater() instead.
Parameters
Authority | UserIdentity$performer
RevisionSlotsUpdate | null$forUpdateIf given, allows any cached ParserOutput that may already have been returned via getDerivedDataUpdater to be re-used.
Returns
PageUpdater

Definition at line 1731 of file WikiPage.php.

◆ onArticleCreate()

static WikiPage::onArticleCreate ( Title $title,
$maybeIsRedirect = true )
static

The onArticle*() functions are supposed to be a kind of hooks which should be called whenever any of the specified actions are done.

This is a good place to put code to clear caches, for instance.

This is called on page move and undelete, as well as edit

Parameters
Title$title
bool$maybeIsRedirectTrue if the page may have been created as a redirect. If false, this is used as a hint to skip some unnecessary updates.

Definition at line 2695 of file WikiPage.php.

References MediaWiki\Title\Title\deleteTitleProtection(), MediaWiki\Title\Title\getNamespace(), MediaWiki\Title\Title\getOtherPage(), NS_CATEGORY, NS_FILE, and MediaWiki\Title\Title\touchLinks().

◆ onArticleDelete()

static WikiPage::onArticleDelete ( Title $title)
static

◆ onArticleEdit()

static WikiPage::onArticleEdit ( Title $title,
RevisionRecord $revRecord = null,
$slotsChanged = null,
$maybeRedirectChanged = true )
static

Purge caches on page update etc.

Parameters
Title$title
RevisionRecord | null$revRecordrevision that was just saved, may be null
string[] | null$slotsChangedThe role names of the slots that were changed. If not given, all slots are assumed to have changed.
bool$maybeRedirectChangedTrue if the page's redirect target may have changed in the latest revision. If false, this is used as a hint to skip some unnecessary updates.

Definition at line 2800 of file WikiPage.php.

References MediaWiki\Revision\RevisionRecord\getId(), MediaWiki\Title\Title\getNamespace(), and NS_FILE.

◆ pageData()

WikiPage::pageData ( $dbr,
$conditions,
$options = [] )
protected

Fetch a page record with the given conditions.

Parameters
IReadableDatabase$dbr
array$conditions
array$options
Returns
stdClass|false Database result resource, or false on failure

Definition at line 352 of file WikiPage.php.

◆ pageDataFromId()

WikiPage::pageDataFromId ( $dbr,
$id,
$options = [] )

Fetch a page record matching the requested ID.

Parameters
IReadableDatabase$dbr
int$id
array$options
Returns
stdClass|false Database result resource, or false on failure

Definition at line 399 of file WikiPage.php.

◆ pageDataFromTitle()

WikiPage::pageDataFromTitle ( $dbr,
$title,
$options = [] )

Fetch a page record matching the Title object's namespace and title using a sanitized title string.

Parameters
IReadableDatabase$dbr
Title$title
array$options
Returns
stdClass|false Database result resource, or false on failure

Definition at line 381 of file WikiPage.php.

◆ prepareContentForEdit()

WikiPage::prepareContentForEdit ( Content $content,
?RevisionRecord $revision,
UserIdentity $user,
$serialFormat = null,
$useStash = true )

Prepare content which is about to be saved.

Prior to 1.30, this returned a stdClass.

Deprecated
since 1.32, use newPageUpdater() or getCurrentUpdate() instead.
Note
Calling without a UserIdentity was separately deprecated from 1.37 to 1.39, since 1.39 the UserIdentity has been required.
Parameters
Content$content
RevisionRecord | null$revisionUsed with vary-revision or vary-revision-id.
UserIdentity$user
string | null$serialFormatIGNORED
bool$useStashUse prepared edit stash
Returns
PreparedEdit
Since
1.21

Definition at line 1949 of file WikiPage.php.

References $content, and MediaWiki\User\UserIdentity\getName().

◆ protectDescription()

WikiPage::protectDescription ( array $limit,
array $expiry )

Builds the description to serve as comment for the edit.

Parameters
array$limitSet of restriction keys
array$expiryPer restriction type expiration
Returns
string

Definition at line 2477 of file WikiPage.php.

References wfMessage().

◆ protectDescriptionLog()

WikiPage::protectDescriptionLog ( array $limit,
array $expiry )

Builds the description to serve as comment for the log entry.

Some bots may parse IRC lines, which are generated from log entries which contain plain protect description text. Keep them in old format to avoid breaking compatibility. TODO: Fix protection log to store structured description and format it on-the-fly.

Parameters
array$limitSet of restriction keys
array$expiryPer restriction type expiration
Returns
string

Definition at line 2519 of file WikiPage.php.

◆ replaceSectionAtRev()

WikiPage::replaceSectionAtRev ( $sectionId,
Content $sectionContent,
$sectionTitle = '',
$baseRevId = null )
Parameters
string | int | null | false$sectionIdSection identifier as a number or string (e.g. 0, 1 or 'T-1'), null/false or an empty string for the whole page or 'new' for a new section.
Content$sectionContentNew content of the section.
string$sectionTitleNew section's subject, only if $section is "new".
int | null$baseRevId
Returns
Content|null New complete article content, or null if error.
Since
1.24

Definition at line 1584 of file WikiPage.php.

References MediaWiki\Revision\RevisionRecord\getContent(), and wfDebug().

◆ replaceSectionContent()

WikiPage::replaceSectionContent ( $sectionId,
Content $sectionContent,
$sectionTitle = '',
$edittime = null )
Parameters
string | int | null | false$sectionIdSection identifier as a number or string (e.g. 0, 1 or 'T-1'), null/false or an empty string for the whole page or 'new' for a new section.
Content$sectionContentNew content of the section.
string$sectionTitleNew section's subject, only if $section is "new".
string$edittimeRevision timestamp or null to use the current revision.
Returns
Content|null New complete article content, or null if error.
Since
1.21
Deprecated
since 1.24, use replaceSectionAtRev instead

Definition at line 1546 of file WikiPage.php.

◆ setTimestamp()

WikiPage::setTimestamp ( $ts)

Set the page timestamp (use only to avoid DB queries)

Parameters
string$tsMW timestamp of last article revision
Returns
void

Definition at line 801 of file WikiPage.php.

◆ shouldCheckParserCache()

WikiPage::shouldCheckParserCache ( ParserOptions $parserOptions,
$oldId )

Should the parser cache be used?

Parameters
ParserOptions$parserOptionsParserOptions to check
int$oldId
Returns
bool

Definition at line 1211 of file WikiPage.php.

◆ supportsSections()

WikiPage::supportsSections ( )

Returns true if this page's content model supports sections.

Returns
bool
Todo

The skin should check this and not offer section functionality if sections are not supported.

The EditPage should check this and not offer section functionality if sections are not supported.

Definition at line 1529 of file WikiPage.php.

◆ toPageRecord()

WikiPage::toPageRecord ( )

Returns the page represented by this WikiPage as a PageStoreRecord.

The PageRecord returned by this method is guaranteed to be immutable.

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

Since
1.36
Exceptions
PreconditionExceptionif the page does not exist.
Returns
ExistingPageRecord

Definition at line 3238 of file WikiPage.php.

Referenced by MediaWiki\Storage\DerivedPageDataUpdater\doParserCacheUpdate().

◆ triggerOpportunisticLinksUpdate()

WikiPage::triggerOpportunisticLinksUpdate ( ParserOutput $parserOutput)

Opportunistically enqueue link update jobs after a fresh parser output was generated.

This method should only be called by PoolWorkArticleViewCurrent, after a page view experienced a miss from the ParserCache, and a new ParserOutput was generated. Specifically, for load reasons, this method must not get called during page views that use a cached ParserOutput.

Since
1.25
Access: internal
For use by PoolWorkArticleViewCurrent
Parameters
ParserOutput$parserOutputCurrent version page output

Definition at line 3053 of file WikiPage.php.

References CacheTime\getCacheExpiry(), CacheTime\getCacheTime(), and ParserOutput\hasReducedExpiry().

◆ updateCategoryCounts()

WikiPage::updateCategoryCounts ( array $added,
array $deleted,
$id = 0 )

Update all the appropriate counts in the category table, given that we've added the categories $added and deleted the categories $deleted.

This should only be called from deferred updates or jobs to avoid contention.

Parameters
string[]$addedThe names of categories that were added
string[]$deletedThe names of categories that were deleted
int$idPage ID (this should be the original deleted page ID)

Definition at line 2960 of file WikiPage.php.

References DB_PRIMARY, getTitle(), and wfGetDB().

◆ updateParserCache()

WikiPage::updateParserCache ( array $options = [])

Update the parser cache.

Note
This does not update links tables. Use doSecondaryDataUpdates() for that.
Parameters
array$options
  • causeAction: an arbitrary string identifying the reason for the update. See DataUpdate::getCauseAction(). (default 'edit-page')
  • causeAgent: name of the user who caused the update (string, defaults to the user who created the revision)
Since
1.32

Definition at line 2033 of file WikiPage.php.

◆ updateRevisionOn()

WikiPage::updateRevisionOn ( $dbw,
RevisionRecord $revision,
$lastRevision = null,
$lastRevIsRedirect = null )

Update the page record to point to a newly saved revision.

Todo
Factor out into a PageStore service, or move into PageUpdater.
Parameters
IDatabase$dbw
RevisionRecord$revisionFor ID number, and text used to set length and redirect status fields.
int | null$lastRevisionIf given, will not overwrite the page field when different from the currently set value. Giving 0 indicates the new page flag should be set on.
bool | null$lastRevIsRedirectIf given, will optimize adding and removing rows in redirect table.
Returns
bool Success; false if the page row was missing or page_latest changed

Definition at line 1391 of file WikiPage.php.

References $content, MediaWiki\Revision\RevisionRecord\getContent(), MediaWiki\Revision\RevisionRecord\getId(), MediaWiki\Revision\RevisionRecord\getSlot(), and MediaWiki\Revision\RevisionRecord\getTimestamp().

◆ wasLoadedFrom()

WikiPage::wasLoadedFrom ( $from)

Checks whether the page data was loaded using the given database access mode (or better).

Since
1.32
Parameters
string | int$fromOne of the following:
  • "fromdb" or WikiPage::READ_NORMAL to get from a replica DB.
  • "fromdbmaster" or WikiPage::READ_LATEST to get from the primary DB.
  • "forupdate" or WikiPage::READ_LOCKING to get from the primary DB using SELECT FOR UPDATE.
Returns
bool

Definition at line 460 of file WikiPage.php.

Member Data Documentation

◆ $mDataLoaded

bool WikiPage::$mDataLoaded = false
protected
Note
for access by subclasses only

Definition at line 94 of file WikiPage.php.

◆ $mDataLoadedFrom

int WikiPage::$mDataLoadedFrom = self::READ_NONE
protected

One of the READ_* constants.

Definition at line 134 of file WikiPage.php.

◆ $mId

int null WikiPage::$mId = null
protected

Definition at line 129 of file WikiPage.php.

◆ $mLanguage

string null WikiPage::$mLanguage = null
protected

Definition at line 154 of file WikiPage.php.

◆ $mLatest

int false WikiPage::$mLatest = false
protected

False means "not loaded".

Note
for access by subclasses only

Definition at line 118 of file WikiPage.php.

◆ $mLinksUpdated

string WikiPage::$mLinksUpdated = '19700101000000'
protected

Definition at line 159 of file WikiPage.php.

◆ $mPreparedEdit

PreparedEdit false WikiPage::$mPreparedEdit = false
protected

Map of cache fields (text, parser output, ect) for a proposed/new edit.

Note
for access by subclasses only

Definition at line 124 of file WikiPage.php.

◆ $mRedirectTarget

Title null WikiPage::$mRedirectTarget = null
protected

The cache of the redirect target.

Definition at line 107 of file WikiPage.php.

◆ $mTimestamp

string WikiPage::$mTimestamp = ''
protected

Timestamp of the current revision or empty string if not loaded.

Definition at line 144 of file WikiPage.php.

◆ $mTitle

Title WikiPage::$mTitle
protected
Note
for access by subclasses only

Definition at line 88 of file WikiPage.php.

◆ $mTouched

string WikiPage::$mTouched = '19700101000000'
protected

Definition at line 149 of file WikiPage.php.


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