MediaWiki REL1_31
WikiPage Class Reference

Class representing a MediaWiki article and history. More...

Inheritance diagram for WikiPage:
Collaboration diagram for WikiPage:

Public Member Functions

 __clone ()
 Makes sure that the mTitle object is cloned to the newly cloned WikiPage.
 
 __construct (Title $title)
 Constructor and clear the article.
 
 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.
 
 commitRollback ( $fromP, $summary, $bot, &$resultDetails, User $guser, $tags=null)
 Backend implementation of doRollback(), please refer there for parameter and return value documentation.
 
 doDeleteArticle ( $reason, $suppress=false, $u1=null, $u2=null, &$error='', User $user=null)
 Same as doDeleteArticleReal(), but returns a simple boolean.
 
 doDeleteArticleReal ( $reason, $suppress=false, $u1=null, $u2=null, &$error='', User $deleter=null, $tags=[], $logsubtype='delete')
 Back-end article deletion Deletes the article with database consistency, writes logs, purges caches.
 
 doDeleteUpdates ( $id, Content $content=null, Revision $revision=null, User $user=null)
 Do some database updates after deletion.
 
 doEditContent (Content $content, $summary, $flags=0, $baseRevId=false, User $user=null, $serialFormat=null, $tags=[], $undidRevId=0)
 Change an existing article or create a new article.
 
 doEditUpdates (Revision $revision, User $user, array $options=[])
 Do standard deferred updates after page edit.
 
 doPurge ()
 Perform the actions of a page purging.
 
 doRollback ( $fromP, $summary, $token, $bot, &$resultDetails, User $user, $tags=null)
 Roll back the most recent consecutive set of edits to a page from the same user; fails if there are no eligible edits to roll back to, e.g.
 
 doUpdateRestrictions (array $limit, array $expiry, &$cascade, $reason, User $user, $tags=null)
 Update the article's restriction field, and leave a log entry.
 
 doViewUpdates (User $user, $oldid=0)
 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)
 Auto-generates a deletion reason.
 
 getCategories ()
 #-
 
 getComment ( $audience=Revision::FOR_PUBLIC, User $user=null)
 
 getContent ( $audience=Revision::FOR_PUBLIC, User $user=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=Revision::FOR_PUBLIC, User $user=null)
 Get the User object of the user who created the page.
 
 getDeletionUpdates (Content $content=null)
 Returns a list of updates to be performed when this page is deleted.
 
 getHiddenCategories ()
 Returns a list of hidden categories this page is a member of.
 
 getId ()
 
 getLatest ()
 Get the page_latest field.
 
 getLinksTimestamp ()
 Get the page_links_updated field.
 
 getMinorEdit ()
 Returns true if last revision was marked as "minor edit".
 
 getMutableCacheKeys (WANObjectCache $cache)
 
 getOldestRevision ()
 Get the Revision object of the oldest revision.
 
 getParserOutput (ParserOptions $parserOptions, $oldid=null, $forceParse=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.
 
 getRevision ()
 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.
 
 getUndoContent (Revision $undo, Revision $undoafter=null)
 Get the content that needs to be saved in order to undo all revisions between $undo and $undoafter.
 
 getUser ( $audience=Revision::FOR_PUBLIC, User $user=null)
 
 getUserText ( $audience=Revision::FOR_PUBLIC, User $user=null)
 
 getWikiDisplayName ()
 The display name for the site this content come from.
 
 hasViewableContent ()
 Check if this page is something we're going to be showing some sort of sensible content for.
 
 insertOn ( $dbw, $pageId=null)
 Insert a new empty page record for this article.
 
 insertProtectNullRevision ( $revCommentMsg, array $limit, array $expiry, $cascade, $reason, $user=null)
 Insert a new null revision for this page.
 
 insertRedirect ()
 Insert an entry for this page into the redirect table if the content is a redirect.
 
 insertRedirectEntry (Title $rt, $oldLatest=null)
 Insert or update the redirect table entry for this page to indicate it redirects to $rt.
 
 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.
 
 isRedirect ()
 Tests if the article content represents a redirect.
 
 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.
 
 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, $revision=null, User $user=null, $serialFormat=null, $useCache=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.
 
 triggerOpportunisticLinksUpdate (ParserOutput $parserOutput)
 Opportunistically enqueue link update jobs given fresh parser output if useful.
 
 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.
 
 updateIfNewerOn ( $dbw, $revision)
 If the given revision is newer than the currently set page_latest, update the page record.
 
 updateRedirectOn ( $dbw, $redirectTitle, $lastRevIsRedirect=null)
 Add row to the redirect table if this is a redirect, remove otherwise.
 
 updateRevisionOn ( $dbw, $revision, $lastRevision=null, $lastRevIsRedirect=null)
 Update the page record to point to a newly saved revision.
 

Static Public Member Functions

static factory (Title $title)
 Create a WikiPage object of the appropriate class for the given title.
 
static getQueryInfo ()
 Return the tables, fields, and join conditions to be selected to create a new page object.
 
static newFromID ( $id, $from='fromdb')
 Constructor from a page id.
 
static newFromRow ( $row, $from='fromdb')
 Constructor from a database row.
 
static onArticleCreate (Title $title)
 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, Revision $revision=null)
 Purge caches on page update etc.
 
static selectFields ()
 Return the list of revision fields that should be selected to create a new page.
 

Public Attributes

PreparedEdit $mPreparedEdit = false
 Map of cache fields (text, parser output, ect) for a proposed/new edit.
 
Title $mTitle = null
 
 $mDataLoaded = false
 
 $mIsRedirect = false
 
 $mLatest = false
 
- Public Attributes inherited from IDBAccessObject
const READ_LOCKING = 3
 Constants for object loading bitfield flags (higher => higher QoS)
 
const READ_NONE = -1
 

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.
 
 setLastEdit (Revision $revision)
 Set the latest revision.
 

Static Protected Member Functions

static flattenRestrictions ( $limit)
 Take an array of page restrictions and flatten it to a string suitable for insertion into the page_restrictions field.
 

Protected Attributes

int $mDataLoadedFrom = self::READ_NONE
 One of the READ_* constants.
 
int $mId = null
 
Revision $mLastRevision = null
 
string $mLinksUpdated = '19700101000000'
 
Title $mRedirectTarget = null
 
string $mTimestamp = ''
 Timestamp of the current revision or empty string if not loaded.
 
string $mTouched = '19700101000000'
 

Private Member Functions

 doCreate (Content $content, $flags, User $user, $summary, array $meta)
 
 doModify (Content $content, $flags, User $user, $summary, array $meta)
 

Static Private Member Functions

static convertSelectType ( $type)
 Convert 'fromdb', 'fromdbmaster' and 'forupdate' to READ_* constants.
 

Detailed Description

Class representing a MediaWiki article and history.

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

Definition at line 37 of file WikiPage.php.

Constructor & Destructor Documentation

◆ __construct()

WikiPage::__construct ( Title $title)

Constructor and clear the article.

Parameters
Title$titleReference to a Title object.

Definition at line 95 of file WikiPage.php.

References $title.

Member Function Documentation

◆ __clone()

WikiPage::__clone ( )

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

Definition at line 103 of file WikiPage.php.

◆ checkFlags()

WikiPage::checkFlags ( $flags)

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

Parameters
int$flags
Returns
int Updated $flags

Definition at line 1509 of file WikiPage.php.

References EDIT_NEW, EDIT_UPDATE, and exists().

Referenced by doEditContent().

◆ 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 591 of file WikiPage.php.

References loadPageData().

◆ clear()

WikiPage::clear ( )

Clear the object.

Returns
void

Definition at line 244 of file WikiPage.php.

References clearCacheFields().

Referenced by ApiEditPageTest\forceRevisionDate(), and EditPageTest\forceRevisionDate().

◆ clearCacheFields()

WikiPage::clearCacheFields ( )
protected

Clear the object cache fields.

Returns
void

Definition at line 255 of file WikiPage.php.

Referenced by clear(), and loadFromRow().

◆ clearPreparedEdit()

WikiPage::clearPreparedEdit ( )

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

Returns
void
Since
1.23

Definition at line 275 of file WikiPage.php.

◆ commitRollback()

WikiPage::commitRollback ( $fromP,
$summary,
$bot,
& $resultDetails,
User $guser,
$tags = null )

Backend implementation of doRollback(), please refer there for parameter and return value documentation.

NOTE: This function does NOT check ANY permissions, it just commits the rollback to the DB. Therefore, you should only call this function direct- ly if you want to use custom permissions checks. If you don't, use doRollback() instead.

Parameters
string$fromPName of the user whose edits to rollback.
string$summaryCustom summary. Set to default summary if empty.
bool$botIf true, mark all reverted edits as bot.
array&$resultDetailsContains result-specific array of additional values
User$guserThe user performing the rollback
array | null$tagsChange tags to apply to the rollback Callers are responsible for permission checks (with ChangeTags::canAddTagsAccompanyingChange)
Returns
array

Definition at line 3158 of file WikiPage.php.

References $args, $s, $wgContLang, $wgUseRCPatrol, DB_MASTER, doEditContent(), EDIT_FORCE_BOT, EDIT_INTERNAL, EDIT_MINOR, EDIT_UPDATE, getRevision(), ChangeTags\getSoftwareTags(), User\newFromId(), User\newFromName(), wfGetDB(), wfMessage(), wfMsgReplaceArgs(), wfReadOnly(), and wfTimestamp().

Referenced by doRollback().

◆ convertSelectType()

static WikiPage::convertSelectType ( $type)
staticprivate

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

Parameters
object | string | int$type
Returns
mixed

Definition at line 195 of file WikiPage.php.

References $type.

◆ doCreate()

WikiPage::doCreate ( Content $content,
$flags,
User $user,
$summary,
array $meta )
private
Parameters
Content$contentPre-save transform content
int$flags
User$user
string$summary
array$meta
Returns
Status
Exceptions
DBUnexpectedError
Exception
FatalError
MWException

Definition at line 1874 of file WikiPage.php.

References $params, $user, $wgUseNPPatrol, $wgUseRCPatrol, DB_MASTER, doEditUpdates(), EDIT_MINOR, EDIT_SUPPRESS_RC, Content\getModel(), Content\getSize(), insertOn(), Content\prepareSave(), updateRevisionOn(), wfGetDB(), and wfTimestampNow().

Referenced by doEditContent().

◆ doDeleteArticle()

WikiPage::doDeleteArticle ( $reason,
$suppress = false,
$u1 = null,
$u2 = null,
& $error = '',
User $user = null )

Same as doDeleteArticleReal(), but returns a simple boolean.

This is kept around for backwards compatibility, if you care about error reporting you should use doDeleteArticleReal() instead.

Deletes the article with database consistency, writes logs, purges caches

Parameters
string$reasonDelete reason for deletion log
bool$suppressSuppress all revisions and log the deletion in the suppression log instead of the deletion log
int$u1Unused
bool$u2Unused
array | string&$errorArray of errors to append to
User$userThe deleting user
Returns
bool True if successful

Definition at line 2760 of file WikiPage.php.

References doDeleteArticleReal().

◆ doDeleteArticleReal()

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

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

Since
1.19
Parameters
string$reasonDelete reason for deletion log
bool$suppressSuppress all revisions and log the deletion in the suppression log instead of the deletion log
int$u1Unused
bool$u2Unused
array | string&$errorArray of errors to append to
User$deleterThe deleting user
array$tagsTags to apply to the deletion action
string$logsubtype
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 2786 of file WikiPage.php.

References $cache, $res, $revQuery, $wgActorTableSchemaMigrationStage, $wgCommentTableSchemaMigrationStage, $wgContentHandlerUseDB, $wgUser, DB_MASTER, doDeleteUpdates(), getContent(), getId(), getLatest(), getRevision(), getTitle(), loadPageData(), lockAndGetLatest(), MIGRATION_OLD, User\newFromAnyId(), wfDebug(), wfEscapeWikiText(), wfGetDB(), and wfLogWarning().

Referenced by doDeleteArticle(), EditPageTest\testCreatePage(), and EditPageTest\testCreatePageTrx().

◆ doDeleteUpdates()

WikiPage::doDeleteUpdates ( $id,
Content $content = null,
Revision $revision = null,
User $user = null )

Do some database updates after deletion.

Parameters
int$idThe page_id value of the page being deleted
Content | null$contentOptional page content to be used when determining the required updates. This may be needed because $this->getContent() may already return null when the page proper was deleted.
Revision | null$revisionThe latest page revision
User | null$userThe user that caused the deletion

Definition at line 3038 of file WikiPage.php.

References SiteStatsUpdate\factory(), getDeletionUpdates(), ResourceLoaderWikiModule\invalidateModuleCache(), isCountable(), loadFromRow(), NS_FILE, LinksUpdate\queueRecursiveJobsForTable(), and wfWikiID().

Referenced by doDeleteArticleReal().

◆ doEditContent()

WikiPage::doEditContent ( Content $content,
$summary,
$flags = 0,
$baseRevId = false,
User $user = null,
$serialFormat = null,
$tags = [],
$undidRevId = 0 )

Change an existing article or create a new article.

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

Parameters
Content$contentNew content
string$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
bool | int$baseRevIdThe revision ID this edit was based off, if any. This is not the parent revision ID, rather the revision ID for older content used as the source for a rollback, for example.
User$userThe user doing the edit
string$serialFormatFormat for storing the content in the database.
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
Exceptions
MWException
Returns
Status 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: The revision object for the inserted revision, or null.

Since
1.21
Exceptions
MWException

Definition at line 1579 of file WikiPage.php.

References $handler, $user, $wgUseAutomaticEditSummaries, $wgUser, checkFlags(), doCreate(), doModify(), EDIT_AUTOSUMMARY, EDIT_FORCE_BOT, EDIT_INTERNAL, EDIT_MINOR, EDIT_UPDATE, getContent(), Content\getContentHandler(), getLatest(), Content\getModel(), getRevision(), ChangeTags\getSoftwareTags(), isCountable(), isRedirect(), loadPageData(), and prepareContentForEdit().

Referenced by commitRollback().

◆ doEditUpdates()

WikiPage::doEditUpdates ( Revision $revision,
User $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.

Parameters
Revision$revision
User$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: Revision 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

Definition at line 2167 of file WikiPage.php.

References $options, $wgRCWatchCategoryMembership, exists(), SiteStatsUpdate\factory(), Revision\getContent(), getContentHandler(), getId(), Revision\getId(), Revision\getTimestamp(), getTitle(), ResourceLoaderWikiModule\invalidateModuleCache(), isCountable(), User\isIP(), Revision\isMinor(), User\newFromName(), RecentChangesUpdateJob\newPurgeJob(), NS_USER_TALK, prepareContentForEdit(), JobQueueGroup\singleton(), MessageCache\singleton(), wfDebug(), and wfWikiID().

Referenced by doCreate(), and doModify().

◆ doModify()

WikiPage::doModify ( Content $content,
$flags,
User $user,
$summary,
array $meta )
private
Parameters
Content$contentPre-save transform content
int$flags
User$user
string$summary
array$meta
Returns
Status
Exceptions
DBUnexpectedError
Exception
FatalError
MWException

Definition at line 1700 of file WikiPage.php.

References $params, $user, $wgUseRCPatrol, DB_MASTER, doEditUpdates(), EDIT_MINOR, EDIT_SUPPRESS_RC, Content\equals(), getId(), Content\getModel(), Content\getSize(), lockAndGetLatest(), Content\prepareSave(), updateRevisionOn(), wfGetDB(), and wfTimestampNow().

Referenced by doEditContent().

◆ 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 WikiFilePage.

Definition at line 1167 of file WikiPage.php.

References HTMLFileCache\clearFileCache(), getContent(), getTitle(), and MessageCache\singleton().

◆ doRollback()

WikiPage::doRollback ( $fromP,
$summary,
$token,
$bot,
& $resultDetails,
User $user,
$tags = null )

Roll back the most recent consecutive set of edits to a page from the same user; fails if there are no eligible edits to roll back to, e.g.

user is the sole contributor. This function performs permissions checks on $user, then calls commitRollback() to do the dirty work

Todo

Separate the business/permission stuff out from backend code

Remove $token parameter. Already verified by RollbackAction and ApiRollback.

Parameters
string$fromPName of the user whose edits to rollback.
string$summaryCustom summary. Set to default summary if empty.
string$tokenRollback token.
bool$botIf true, mark all reverted edits as bot.
array&$resultDetailsArray contains result-specific array of additional values 'alreadyrolled' : 'current' (rev) success : 'summary' (str), 'current' (rev), 'target' (rev)
User$userThe user performing the rollback
array | null$tagsChange tags to apply to the rollback Callers are responsible for permission checks (with ChangeTags::canAddTagsAccompanyingChange)
Returns
array Array of errors, each error formatted as array(messagekey, param1, param2, ...). On success, the array is empty. This array can also be passed to OutputPage::showPermissionsErrorPage().

Definition at line 3112 of file WikiPage.php.

References commitRollback(), and wfArrayDiff2().

◆ doUpdateRestrictions()

WikiPage::doUpdateRestrictions ( array $limit,
array $expiry,
& $cascade,
$reason,
User $user,
$tags = null )

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
int&$cascadeSet to false if cascading protection isn't allowed.
string$reason
User$userThe user updating the restrictions
string | 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 2343 of file WikiPage.php.

References $params, $wgCascadingRestrictionLevels, DB_MASTER, getId(), getLatest(), insertProtectNullRevision(), InfoAction\invalidateCache(), loadPageData(), protectDescriptionLog(), wfGetDB(), wfMessage(), wfReadOnly(), and wfReadOnlyReason().

◆ doViewUpdates()

WikiPage::doViewUpdates ( User $user,
$oldid = 0 )

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

Parameters
User$userThe relevant user
int$oldidRevision id being viewed; if not given or 0, latest revision is assumed

Definition at line 1144 of file WikiPage.php.

References wfReadOnly().

◆ exists()

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

Definition at line 520 of file WikiPage.php.

References loadPageData().

Referenced by LinksDeletionUpdate\__construct(), checkFlags(), doEditUpdates(), getContentModel(), and shouldCheckParserCache().

◆ factory()

static WikiPage::factory ( Title $title)
static

Create a WikiPage object of the appropriate class for the given title.

Parameters
Title$title
Exceptions
MWException
Returns
WikiPage|WikiCategoryPage|WikiFilePage

Definition at line 115 of file WikiPage.php.

References NS_CATEGORY, NS_FILE, and NS_MEDIA.

Referenced by MediaWiki\Tests\Storage\RevisionStoreDbTest\getRevisionRecordFromDetailsArray(), RecentChange\newForCategorization(), MediaWiki\Tests\Storage\RevisionStoreDbTest\revisionToRow(), MediaWiki\Tests\Storage\RevisionStoreDbTest\testCountRevisionsByPageId(), MediaWiki\Tests\Storage\RevisionStoreDbTest\testCountRevisionsByTitle(), MediaWiki\Tests\Storage\RevisionStoreDbTest\testGetKnownCurrentRevision(), MediaWiki\Tests\Storage\RevisionStoreDbTest\testGetNextRevision(), MediaWiki\Tests\Storage\RevisionStoreDbTest\testGetParentLengths(), MediaWiki\Tests\Storage\RevisionStoreDbTest\testGetPreviousRevision(), MediaWiki\Tests\Storage\RevisionStoreDbTest\testGetRcIdIfUnpatrolled_returnsRecentChangesId(), MediaWiki\Tests\Storage\RevisionStoreDbTest\testGetRcIdIfUnpatrolled_returnsZeroIfPatrolled(), MediaWiki\Tests\Storage\RevisionStoreDbTest\testGetRecentChange(), MediaWiki\Tests\Storage\RevisionStoreDbTest\testGetRevisionById(), MediaWiki\Tests\Storage\RevisionStoreDbTest\testGetRevisionByPageId(), MediaWiki\Tests\Storage\RevisionStoreDbTest\testGetRevisionByTimestamp(), MediaWiki\Tests\Storage\RevisionStoreDbTest\testGetRevisionByTitle(), MediaWiki\Tests\Storage\RevisionStoreDbTest\testGetTimestampFromId_found(), MediaWiki\Tests\Storage\RevisionStoreDbTest\testGetTimestampFromId_notFound(), WikiCategoryPageTest\testHiddenCategory_PropertyIsSet(), WikiCategoryPageTest\testHiddenCategory_PropertyNotSet(), MediaWiki\Tests\Storage\RevisionStoreDbTest\testLoadRevisionFromId(), MediaWiki\Tests\Storage\RevisionStoreDbTest\testLoadRevisionFromPageId(), MediaWiki\Tests\Storage\RevisionStoreDbTest\testLoadRevisionFromTimestamp(), MediaWiki\Tests\Storage\RevisionStoreDbTest\testLoadRevisionFromTitle(), MediaWiki\Tests\Storage\RevisionStoreDbTest\testNewRevisionFromArchiveRow(), MediaWiki\Tests\Storage\RevisionStoreDbTest\testNewRevisionFromArchiveRow_legacyEncoding(), MediaWiki\Tests\Storage\RevisionStoreDbTest\testNewRevisionFromRow_anonEdit(), MediaWiki\Tests\Storage\RevisionStoreDbTest\testNewRevisionFromRow_anonEdit_legacyEncoding(), MediaWiki\Tests\Storage\RevisionStoreDbTest\testNewRevisionFromRow_userEdit(), MediaWiki\Tests\Storage\RevisionStoreDbTest\testUserWasLastToEdit_false(), and MediaWiki\Tests\Storage\RevisionStoreDbTest\testUserWasLastToEdit_true().

◆ flattenRestrictions()

static WikiPage::flattenRestrictions ( $limit)
staticprotected

Take an array of page restrictions and flatten it to a string suitable for insertion into the page_restrictions field.

Parameters
string[]$limit
Exceptions
MWException
Returns
string

Definition at line 2729 of file WikiPage.php.

◆ 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 984 of file WikiPage.php.

References getRedirectTarget(), and getRedirectURL().

◆ formatExpiry()

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

Definition at line 2641 of file WikiPage.php.

References $wgContLang, and wfMessage().

Referenced by protectDescription(), and protectDescriptionLog().

◆ getActionOverrides()

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

Definition at line 215 of file WikiPage.php.

References getContentHandler().

◆ getAutoDeleteReason()

WikiPage::getAutoDeleteReason ( & $hasHistory)

Auto-generates a deletion reason.

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

Definition at line 3527 of file WikiPage.php.

References getContentHandler(), and getTitle().

◆ getCategories()

WikiPage::getCategories ( )

#-

Returns a list of categories this page is a member of. Results will include hidden categories

Returns
TitleArray

Definition at line 3473 of file WikiPage.php.

References $dbr, $res, DB_REPLICA, getId(), TitleArray\newFromResult(), NS_CATEGORY, and wfGetDB().

◆ getComment()

WikiPage::getComment ( $audience = Revision::FOR_PUBLIC,
User $user = null )
Parameters
int$audienceOne of: Revision::FOR_PUBLIC to be displayed to all users Revision::FOR_THIS_USER to be displayed to the given user Revision::RAW get the text regardless of permissions
User$userUser object to check for, only if FOR_THIS_USER is passed to the $audience parameter
Returns
string Comment stored for the last article revision

Definition at line 812 of file WikiPage.php.

References loadLastEdit().

◆ getContent()

WikiPage::getContent ( $audience = Revision::FOR_PUBLIC,
User $user = null )

Get the content of the current revision.

No side-effects...

Parameters
int$audienceOne of: Revision::FOR_PUBLIC to be displayed to all users Revision::FOR_THIS_USER to be displayed to $wgUser Revision::RAW get the text regardless of permissions
User$userUser object 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 718 of file WikiPage.php.

References loadLastEdit().

Referenced by doDeleteArticleReal(), doEditContent(), doPurge(), ContentHandler\getDataForSearchIndex(), TextContentHandler\getDataForSearchIndex(), getDeletionUpdates(), ApiParse\getParsedContent(), ContentHandler\getParserOutputForIndexing(), EditPage\getPreloadedContent(), insertRedirect(), isCountable(), prepareContentForEdit(), replaceSectionAtRev(), and ContentHandlerTest\testDataIndexFields().

◆ 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 228 of file WikiPage.php.

Referenced by doEditUpdates(), getActionOverrides(), getAutoDeleteReason(), makeParserOptions(), replaceSectionAtRev(), shouldCheckParserCache(), supportsSections(), and ContentHandlerTest\testDataIndexFields().

◆ 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 562 of file WikiPage.php.

References $cache, $rev, exists(), function, getRevision(), and wfWarn().

◆ 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 1033 of file WikiPage.php.

References $dbr, $options, $res, $tables, DB_REPLICA, getId(), getUser(), getUserText(), User\newFromId(), User\newFromName(), and wfGetDB().

◆ getCreator()

WikiPage::getCreator ( $audience = Revision::FOR_PUBLIC,
User $user = null )

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

Parameters
int$audienceOne of: Revision::FOR_PUBLIC to be displayed to all users Revision::FOR_THIS_USER to be displayed to the given user Revision::RAW get the text regardless of permissions
User$userUser object to check for, only if FOR_THIS_USER is passed to the $audience parameter
Returns
User|null

Definition at line 775 of file WikiPage.php.

References getOldestRevision(), and User\newFromName().

◆ getDeletionUpdates()

WikiPage::getDeletionUpdates ( Content $content = null)

Returns a list of updates to be performed when this page is deleted.

The updates should remove any information about this page from secondary data stores such as links tables.

Parameters
Content | null$contentOptional Content object for determining the necessary updates.
Returns
DeferrableUpdate[]

Definition at line 3697 of file WikiPage.php.

References getContent().

Referenced by doDeleteUpdates().

◆ getHiddenCategories()

WikiPage::getHiddenCategories ( )

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

Uses the page_props and categorylinks tables.

Returns
array Array of Title objects

Definition at line 3496 of file WikiPage.php.

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

◆ getId()

◆ getLatest()

◆ getLinksTimestamp()

WikiPage::getLinksTimestamp ( )

Get the page_links_updated field.

Returns
string|null Containing GMT timestamp

Definition at line 613 of file WikiPage.php.

References loadPageData().

Referenced by triggerOpportunisticLinksUpdate().

◆ 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 826 of file WikiPage.php.

References loadLastEdit().

◆ getMutableCacheKeys()

WikiPage::getMutableCacheKeys ( WANObjectCache $cache)
Parameters
WANObjectCache$cache
Returns
string[]
Since
1.28

Definition at line 3763 of file WikiPage.php.

References $cache, and getTitle().

◆ getOldestRevision()

WikiPage::getOldestRevision ( )

Get the Revision object of the oldest revision.

Returns
Revision|null

Definition at line 635 of file WikiPage.php.

References $rev.

Referenced by getCreator().

◆ getParserOutput()

WikiPage::getParserOutput ( ParserOptions $parserOptions,
$oldid = null,
$forceParse = 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.

Since
1.19
Parameters
ParserOptions$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$forceParseForce reindexing, regardless of cache settings
Returns
bool|ParserOutput ParserOutput or false if the revision was not found

Definition at line 1103 of file WikiPage.php.

References getLatest(), ParserOptions\getStubThreshold(), ParserOptions\isSafeToCache(), shouldCheckParserCache(), wfDebug(), and wfIncrStats().

Referenced by ApiParse\getParsedContent(), and DifferenceEngine\getParserOutput().

◆ 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 IDatabase->select()
  • fields: (string[]) to include in the $vars to IDatabase->select()
  • joins: (array) to include in the $join_conds to IDatabase->select()

Definition at line 325 of file WikiPage.php.

References $ret, $wgContentHandlerUseDB, and $wgPageLanguageUseDB.

◆ getRedirectTarget()

WikiPage::getRedirectTarget ( )

If this page is a redirect, get its target.

The target will be fetched from the redirect table if possible. If this page doesn't have an entry there, call insertRedirect()

Returns
Title|null Title object, or null if this page is not a redirect

Reimplemented in WikiFilePage.

Definition at line 887 of file WikiPage.php.

References $dbr, DB_REPLICA, getId(), insertRedirect(), and wfGetDB().

Referenced by followRedirect(), and EditPage\getPreloadedContent().

◆ 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
bool|Title|string False, Title object of local target, or string with URL

Definition at line 995 of file WikiPage.php.

References $source.

Referenced by followRedirect().

◆ getRevision()

WikiPage::getRevision ( )

◆ 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 3754 of file WikiPage.php.

References getTitle().

◆ getTimestamp()

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

Definition at line 729 of file WikiPage.php.

References loadLastEdit(), and wfTimestamp().

◆ getTitle()

◆ getTouched()

WikiPage::getTouched ( )

Get the page_touched field.

Returns
string Containing GMT timestamp

Definition at line 602 of file WikiPage.php.

References loadPageData().

Referenced by triggerOpportunisticLinksUpdate().

◆ getUndoContent()

WikiPage::getUndoContent ( Revision $undo,
Revision $undoafter = null )

Get the content that needs to be saved in order to undo all revisions between $undo and $undoafter.

Revisions must belong to the same page, must exist and must not be deleted

Parameters
Revision$undo
Revision$undoafterMust be an earlier revision than $undo
Returns
Content|bool Content on success, false on failure
Since
1.21 Before we had the Content object, this was done in getUndoText

Definition at line 1395 of file WikiPage.php.

References $handler, and getRevision().

◆ getUser()

WikiPage::getUser ( $audience = Revision::FOR_PUBLIC,
User $user = null )
Parameters
int$audienceOne of: Revision::FOR_PUBLIC to be displayed to all users Revision::FOR_THIS_USER to be displayed to the given user Revision::RAW get the text regardless of permissions
User$userUser object to check for, only if FOR_THIS_USER is passed to the $audience parameter
Returns
int User ID for the user that made the last article revision

Definition at line 756 of file WikiPage.php.

References loadLastEdit().

Referenced by getContributors().

◆ getUserText()

WikiPage::getUserText ( $audience = Revision::FOR_PUBLIC,
User $user = null )
Parameters
int$audienceOne of: Revision::FOR_PUBLIC to be displayed to all users Revision::FOR_THIS_USER to be displayed to the given user Revision::RAW get the text regardless of permissions
User$userUser object to check for, only if FOR_THIS_USER is passed to the $audience parameter
Returns
string Username of the user that made the last article revision

Definition at line 794 of file WikiPage.php.

References loadLastEdit().

Referenced by getContributors().

◆ 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 3741 of file WikiPage.php.

References $wgSitename.

◆ 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 535 of file WikiPage.php.

◆ 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.

Parameters
IDatabase$dbw
int | null$pageIdCustom page ID that will be used for the insert statement
Returns
bool|int 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 1207 of file WikiPage.php.

References wfRandom().

Referenced by doCreate().

◆ insertProtectNullRevision()

WikiPage::insertProtectNullRevision ( $revCommentMsg,
array $limit,
array $expiry,
$cascade,
$reason,
$user = null )

Insert a new null revision for this page.

Parameters
string$revCommentMsgComment message key for the revision
array$limitSet of restriction keys
array$expiryPer restriction type expiration
int$cascadeSet to false if cascading protection isn't allowed.
string$reason
User | null$user
Returns
Revision|null Null on error

Definition at line 2598 of file WikiPage.php.

References DB_MASTER, getId(), protectDescription(), text, updateRevisionOn(), wfGetDB(), and wfMessage().

Referenced by doUpdateRestrictions().

◆ 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.

Returns
Title|null Title object or null if not a redirect

Definition at line 926 of file WikiPage.php.

References $retval, DB_MASTER, getContent(), getLatest(), insertRedirectEntry(), and wfGetDB().

Referenced by getRedirectTarget().

◆ insertRedirectEntry()

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

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

Parameters
Title$rtRedirect target
int | null$oldLatestPrior page_latest for check and set

Definition at line 951 of file WikiPage.php.

References DB_MASTER, getId(), lockAndGetLatest(), and wfGetDB().

Referenced by insertRedirect(), and updateRedirectOn().

◆ 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 | bool$editInfo(false): object returned by prepareTextForEdit(), if false, the current database state will be used
Returns
bool

Definition at line 843 of file WikiPage.php.

References $wgArticleCountMethod, DB_REPLICA, getContent(), getId(), and wfGetDB().

Referenced by doDeleteUpdates(), doEditContent(), and doEditUpdates().

◆ 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 3728 of file WikiPage.php.

◆ isRedirect()

WikiPage::isRedirect ( )

Tests if the article content represents a redirect.

Returns
bool

Reimplemented in WikiFilePage.

Definition at line 544 of file WikiPage.php.

References loadPageData().

Referenced by doEditContent(), and EditPage\getPreloadedContent().

◆ loadFromRow()

WikiPage::loadFromRow ( $data,
$from )

Load the object from a database row.

Since
1.20
Parameters
object | bool$dataDB row containing fields returned by selectFields() 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 master DB
  • "forupdate" or WikiPage::READ_LOCKING if the data comes from the master DB using SELECT FOR UPDATE

Definition at line 470 of file WikiPage.php.

References clearCacheFields(), wfTimestamp(), and wfTimestampOrNull().

Referenced by doDeleteUpdates(), and loadPageData().

◆ 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 648 of file WikiPage.php.

References $dbr, DB_REPLICA, getId(), getLatest(), getTitle(), IDBAccessObject\READ_LOCKING, setLastEdit(), and wfGetDB().

Referenced by getComment(), getContent(), getMinorEdit(), getRevision(), getTimestamp(), getUser(), and getUserText().

◆ loadPageData()

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

Load the object from a given source by title.

Parameters
object | 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 master DB.
  • "forupdate" or WikiPage::READ_LOCKING to get from the master DB using SELECT FOR UPDATE.
Returns
void

Definition at line 427 of file WikiPage.php.

References DB_REPLICA, list, loadFromRow(), and pageDataFromTitle().

Referenced by checkTouched(), doDeleteArticleReal(), doEditContent(), doUpdateRestrictions(), exists(), getId(), getLatest(), getLinksTimestamp(), getTouched(), and isRedirect().

◆ 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 3012 of file WikiPage.php.

References DB_MASTER, getId(), getTitle(), and wfGetDB().

Referenced by doDeleteArticleReal(), doModify(), and insertRedirectEntry().

◆ makeParserOptions()

WikiPage::makeParserOptions ( $context)

Get parser options suitable for rendering the primary article wikitext.

See also
ContentHandler::makeParserOptions
Parameters
IContextSource | User | string$contextOne of the following:
  • IContextSource: Use the User and the Language of the provided context
  • User: Use the provided User 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 2000 of file WikiPage.php.

References $context, $options, getContentHandler(), and getTitle().

Referenced by DifferenceEngine\getParserOutput(), ContentHandler\getParserOutputForIndexing(), and prepareContentForEdit().

◆ newFromID()

static WikiPage::newFromID ( $id,
$from = 'fromdb' )
static

Constructor from a page id.

Parameters
int$idArticle ID to load
string | int$fromOne of the following values:
  • "fromdb" or WikiPage::READ_NORMAL to select from a replica DB
  • "fromdbmaster" or WikiPage::READ_LATEST to select from the master database
Returns
WikiPage|null

Definition at line 153 of file WikiPage.php.

References DB_MASTER, DB_REPLICA, and wfGetDB().

◆ newFromRow()

static WikiPage::newFromRow ( $row,
$from = 'fromdb' )
static

Constructor from a database row.

Since
1.20
Parameters
object$rowDatabase row containing at least fields returned by selectFields().
string | int$fromSource of $data:
  • "fromdb" or WikiPage::READ_NORMAL: from a replica DB
  • "fromdbmaster" or WikiPage::READ_LATEST: from the master DB
  • "forupdate" or WikiPage::READ_LOCKING: from the master DB using SELECT FOR UPDATE
Returns
WikiPage

Definition at line 183 of file WikiPage.php.

◆ onArticleCreate()

static WikiPage::onArticleCreate ( Title $title)
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

Definition at line 3363 of file WikiPage.php.

References NS_CATEGORY.

◆ onArticleDelete()

static WikiPage::onArticleDelete ( Title $title)
static

◆ onArticleEdit()

static WikiPage::onArticleEdit ( Title $title,
Revision $revision = null )
static

Purge caches on page update etc.

Parameters
Title$title
Revision | null$revisionRevision that was just saved, may be null

Definition at line 3441 of file WikiPage.php.

References HTMLFileCache\clearFileCache(), and InfoAction\invalidateCache().

◆ pageData()

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

Fetch a page record with the given conditions.

Parameters
IDatabase$dbr
array$conditions
array$options
Returns
object|bool Database result resource, or false on failure

Definition at line 364 of file WikiPage.php.

References $dbr, and $options.

Referenced by pageDataFromId(), and pageDataFromTitle().

◆ pageDataFromId()

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

Fetch a page record matching the requested ID.

Parameters
IDatabase$dbr
int$id
array$options
Returns
object|bool Database result resource, or false on failure

Definition at line 411 of file WikiPage.php.

References $dbr, $options, and pageData().

◆ pageDataFromTitle()

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

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

Parameters
IDatabase$dbr
Title$title
array$options
Returns
object|bool Database result resource, or false on failure

Definition at line 397 of file WikiPage.php.

References $dbr, $options, and pageData().

Referenced by loadPageData().

◆ prepareContentForEdit()

WikiPage::prepareContentForEdit ( Content $content,
$revision = null,
User $user = null,
$serialFormat = null,
$useCache = true )

Prepare content which is about to be saved.

Prior to 1.30, this returned a stdClass object with the same class members.

Parameters
Content$content
Revision | int | null$revisionRevision object. For backwards compatibility, a revision ID is also accepted, but this is deprecated.
User | null$user
string | null$serialFormat
bool$useCacheCheck shared prepared edit cache
Returns
PreparedEdit
Since
1.21

Definition at line 2029 of file WikiPage.php.

References $parser, $user, $wgAjaxEditStash, $wgContLang, $wgUser, ApiStashEdit\checkCache(), DB_MASTER, DB_REPLICA, getContent(), Content\getContentHandler(), getTitle(), makeParserOptions(), Content\preSaveTransform(), wfDeprecated(), wfGetDB(), and wfTimestampNow().

Referenced by doEditContent(), doEditUpdates(), ApiStashEdit\parseAndStash(), and SimpleCaptcha\shouldCheck().

◆ 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 2664 of file WikiPage.php.

References formatExpiry(), and wfMessage().

Referenced by insertProtectNullRevision().

◆ 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 2706 of file WikiPage.php.

References $wgContLang, and formatExpiry().

Referenced by doUpdateRestrictions().

◆ replaceSectionAtRev()

WikiPage::replaceSectionAtRev ( $sectionId,
Content $sectionContent,
$sectionTitle = '',
$baseRevId = null )
Parameters
string | int | null | bool$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
Exceptions
MWException
Returns
Content|null New complete article content, or null if error.
Since
1.24

Definition at line 1467 of file WikiPage.php.

References $rev, getContent(), getContentHandler(), getId(), supportsSections(), and wfDebug().

Referenced by replaceSectionContent().

◆ replaceSectionContent()

WikiPage::replaceSectionContent ( $sectionId,
Content $sectionContent,
$sectionTitle = '',
$edittime = null )
Parameters
string | int | null | bool$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.
Exceptions
MWException
Returns
Content|null New complete article content, or null if error.
Since
1.21
Deprecated
since 1.24, use replaceSectionAtRev instead

Definition at line 1428 of file WikiPage.php.

References $dbr, $rev, DB_MASTER, DB_REPLICA, and replaceSectionAtRev().

◆ selectFields()

static WikiPage::selectFields ( )
static

Return the list of revision fields that should be selected to create a new page.

Deprecated
since 1.31, use self::getQueryInfo() instead.
Returns
array

Definition at line 286 of file WikiPage.php.

References $wgContentHandlerUseDB, $wgPageLanguageUseDB, and wfDeprecated().

◆ setLastEdit()

WikiPage::setLastEdit ( Revision $revision)
protected

Set the latest revision.

Parameters
Revision$revision

Definition at line 688 of file WikiPage.php.

References Revision\getTimestamp().

Referenced by loadLastEdit(), and updateRevisionOn().

◆ 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 743 of file WikiPage.php.

References wfTimestamp().

◆ shouldCheckParserCache()

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

Should the parser cache be used?

Parameters
ParserOptions$parserOptionsParserOptions to check
int$oldId
Returns
bool

Definition at line 1083 of file WikiPage.php.

References exists(), getContentHandler(), getLatest(), and ParserOptions\getStubThreshold().

Referenced by getParserOutput().

◆ 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 1410 of file WikiPage.php.

References getContentHandler().

Referenced by replaceSectionAtRev().

◆ triggerOpportunisticLinksUpdate()

WikiPage::triggerOpportunisticLinksUpdate ( ParserOutput $parserOutput)

Opportunistically enqueue link update jobs given fresh parser output if useful.

Parameters
ParserOutput$parserOutputCurrent version page output
Since
1.25

Definition at line 3643 of file WikiPage.php.

References $cache, $params, CacheTime\getCacheExpiry(), CacheTime\getCacheTime(), getId(), getLinksTimestamp(), RequestContext\getMain(), getTouched(), ParserOutput\hasDynamicContent(), RefreshLinksJob\newDynamic(), RefreshLinksJob\newPrioritized(), JobQueueGroup\singleton(), and wfReadOnly().

◆ 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
array$addedThe names of categories that were added
array$deletedThe names of categories that were deleted
int$idPage ID (this should be the original deleted page ID)

Definition at line 3541 of file WikiPage.php.

References $rows, DB_MASTER, getId(), getTitle(), NS_CATEGORY, NS_FILE, and wfGetDB().

◆ updateIfNewerOn()

WikiPage::updateIfNewerOn ( $dbw,
$revision )

If the given revision is newer than the currently set page_latest, update the page record.

Otherwise, do nothing.

Deprecated
since 1.24, use updateRevisionOn instead
Parameters
IDatabase$dbw
Revision$revision
Returns
bool

Definition at line 1359 of file WikiPage.php.

References $ret, getId(), updateRevisionOn(), and wfTimestamp().

◆ updateRedirectOn()

WikiPage::updateRedirectOn ( $dbw,
$redirectTitle,
$lastRevIsRedirect = null )

Add row to the redirect table if this is a redirect, remove otherwise.

Parameters
IDatabase$dbw
Title | null$redirectTitleTitle object pointing to the redirect target, or NULL if this is not a redirect
null | bool$lastRevIsRedirectIf given, will optimize adding and removing rows in redirect table.
Returns
bool True on success, false on failure
Access:\n private

Definition at line 1324 of file WikiPage.php.

References getId(), getTitle(), insertRedirectEntry(), NS_FILE, and RepoGroup\singleton().

Referenced by updateRevisionOn().

◆ updateRevisionOn()

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

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

Parameters
IDatabase$dbw
Revision$revisionFor ID number, and text used to set length and redirect status fields
int$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$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 1250 of file WikiPage.php.

References $result, $wgContentHandlerUseDB, getId(), setLastEdit(), and updateRedirectOn().

Referenced by doCreate(), doModify(), insertProtectNullRevision(), and updateIfNewerOn().

Member Data Documentation

◆ $mDataLoaded

WikiPage::$mDataLoaded = false

{

Access:\n protected

Definition at line 48 of file WikiPage.php.

◆ $mDataLoadedFrom

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

One of the READ_* constants.

Definition at line 64 of file WikiPage.php.

◆ $mId

int WikiPage::$mId = null
protected

Definition at line 59 of file WikiPage.php.

◆ $mIsRedirect

WikiPage::$mIsRedirect = false

{

Access:\n protected

Definition at line 49 of file WikiPage.php.

◆ $mLastRevision

Revision WikiPage::$mLastRevision = null
protected

Definition at line 74 of file WikiPage.php.

◆ $mLatest

WikiPage::$mLatest = false

{

Access:\n protected

Definition at line 50 of file WikiPage.php.

◆ $mLinksUpdated

string WikiPage::$mLinksUpdated = '19700101000000'
protected

Definition at line 89 of file WikiPage.php.

◆ $mPreparedEdit

PreparedEdit WikiPage::$mPreparedEdit = false

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

Definition at line 54 of file WikiPage.php.

◆ $mRedirectTarget

Title WikiPage::$mRedirectTarget = null
protected

Definition at line 69 of file WikiPage.php.

Referenced by WikiFilePage\getRedirectTarget().

◆ $mTimestamp

string WikiPage::$mTimestamp = ''
protected

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

Definition at line 79 of file WikiPage.php.

◆ $mTitle

Title WikiPage::$mTitle = null

Definition at line 43 of file WikiPage.php.

Referenced by WikiFilePage\getForeignCategories().

◆ $mTouched

string WikiPage::$mTouched = '19700101000000'
protected

Definition at line 84 of file WikiPage.php.


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