MediaWiki  REL1_24
WikiPage Class Reference

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

Inheritance diagram for WikiPage:
Collaboration diagram for WikiPage:

List of all members.

Public Member Functions

 __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)
 Backend implementation of doRollback(), please refer there for parameter and return value documentation.
 doCascadeProtectionUpdates (ParserOutput $parserOutput)
 Updates cascading protections.
 doDeleteArticle ($reason, $suppress=false, $id=0, $commit=true, &$error= '', User $user=null)
 Same as doDeleteArticleReal(), but returns a simple boolean.
 doDeleteArticleReal ($reason, $suppress=false, $id=0, $commit=true, &$error= '', User $user=null)
 Back-end article deletion Deletes the article with database consistency, writes logs, purges caches.
 doDeleteUpdates ($id, Content $content=null)
 Do some database updates after deletion.
 doEdit ($text, $summary, $flags=0, $baseRevId=false, $user=null)
 Change an existing article or create a new article.
 doEditContent (Content $content, $summary, $flags=0, $baseRevId=false, User $user=null, $serialisation_format=null)
 Change an existing article or create a new article.
 doEditUpdates (Revision $revision, User $user, array $options=array())
 Do standard deferred updates after page edit.
 doPurge ()
 Perform the actions of a page purging.
 doQuickEdit ($text, User $user, $comment= '', $minor=0)
 Edit an article without doing all that other stuff The article must already exist; link tables etc are not updated, caches are not flushed.
 doQuickEditContent (Content $content, User $user, $comment= '', $minor=false, $serialisation_format=null)
 Edit an article without doing all that other stuff The article must already exist; link tables etc are not updated, caches are not flushed.
 doRollback ($fromP, $summary, $token, $bot, &$resultDetails, User $user)
 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)
 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 ()
 Returns overrides for action handlers.
 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.
 getCount ()
 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 ()
 getLastNAuthors ($num, $revLatest=0)
 Get the last N authors.
 getLatest ()
 Get the page_latest field.
 getLinksTimestamp ()
 Get the page_links_updated field.
 getMinorEdit ()
 Returns true if last revision was marked as "minor edit".
 getOldestRevision ()
 Get the Revision object of the oldest revision.
 getParserOutput (ParserOptions $parserOptions, $oldid=null)
 Get a ParserOutput for the given ParserOptions and revision ID.
 getRawText ()
 Get the text of the current revision.
 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.
 getText ($audience=Revision::FOR_PUBLIC, User $user=null)
 Get the text of the current revision.
 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.
 getUndoText (Revision $undo, Revision $undoafter=null)
 Get the text that needs to be saved in order to undo all revisions between $undo and $undoafter.
 getUsedTemplates ()
 Return a list of templates used by this article.
 getUser ($audience=Revision::FOR_PUBLIC, User $user=null)
 getUserText ($audience=Revision::FOR_PUBLIC, User $user=null)
 hasViewableContent ()
 Check if this page is something we're going to be showing some sort of sensible content for.
 insertOn ($dbw)
 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.
 insertRedirectEntry ($rt)
 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.
 isParserCacheUsed (ParserOptions $parserOptions, $oldid)
 Should the parser cache be used?
 isRedirect ()
 Tests if the article content represents a redirect.
 loadFromRow ($data, $from)
 Load the object from a database row.
 loadPageData ($from= 'fromdb')
 Set the general counter, title etc data loaded from some source.
 makeParserOptions ($context)
 Get parser options suitable for rendering the primary article wikitext.
 pageDataFromId ($dbr, $id, $options=array())
 Fetch a page record matching the requested ID.
 pageDataFromTitle ($dbr, $title, $options=array())
 Fetch a page record matching the Title object's namespace and title using a sanitized title string.
 prepareContentForEdit (Content $content, $revid=null, User $user=null, $serialization_format=null)
 Prepare content which is about to be saved.
 prepareTextForEdit ($text, $revid=null, User $user=null)
 Prepare text which is about to be saved.
 preSaveTransform ($text, User $user=null, ParserOptions $popts=null)
 This function is called right before saving the wikitext, so we can do things like signatures and links-in-context.
 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.
 replaceSection ($sectionId, $text, $sectionTitle= '', $edittime=null)
 replaceSectionAtRev ($sectionId, Content $sectionContent, $sectionTitle= '', $baseRevId=null)
 replaceSectionContent ($sectionId, Content $sectionContent, $sectionTitle= '', $edittime=null)
 setCachedLastEditTime ($timestamp)
 Set the cached timestamp for the last time the page changed.
 setTimestamp ($ts)
 Set the page timestamp (use only to avoid DB queries)
 supportsSections ()
 Returns true if this page's content model supports sections.
 updateCategoryCounts (array $added, array $deleted)
 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.
 updateRestrictions ($limit=array(), $reason= '', &$cascade=0, $expiry=array(), User $user=null)
 Update the article's restriction field, and leave a log entry.
 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 getAutosummary ($oldtext, $newtext, $flags)
 Return an applicable autosummary if one exists for the given edit.
static newFromID ($id, $from= 'fromdb')
 Constructor from a page id.
static newFromRow ($row, $from= 'fromdb')
 Constructor from a database row.
static onArticleCreate ($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)
 Clears caches when article is deleted.
static onArticleEdit ($title)
 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

 $mPreparedEdit = false
Title $mTitle = null
 $mDataLoaded = false
 $mIsRedirect = false
 $mLatest = false

Protected Member Functions

 clearCacheFields ()
 Clear the object cache fields.
 formatExpiry ($expiry)
 getCachedLastEditTime ()
 Get the cached timestamp for the last time the page changed.
 loadLastEdit ()
 Loads everything except the text This isn't necessary for all uses, so it's only done if needed.
 pageData ($dbr, $conditions, $options=array())
 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 null $mCounter = null
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'

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

Constructor and clear the article.

Parameters:
Title$titleReference to a Title object.

Definition at line 91 of file WikiPage.php.


Member Function Documentation

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

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

Returns:
bool True if not a redirect

Definition at line 526 of file WikiPage.php.

Clear the object.

Returns:
void

Definition at line 228 of file WikiPage.php.

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

WikiPage::clearCacheFields ( ) [protected]

Clear the object cache fields.

Returns:
void

Definition at line 239 of file WikiPage.php.

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

Returns:
void
Since:
1.23

Definition at line 260 of file WikiPage.php.

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

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
Returns:
array

Definition at line 2995 of file WikiPage.php.

static WikiPage::convertSelectType ( type) [static, private]

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

Parameters:
object | string | int$type
Returns:
mixed

Definition at line 174 of file WikiPage.php.

Updates cascading protections.

Parameters:
ParserOutput$parserOutputParserOutput object for the current version

Definition at line 3400 of file WikiPage.php.

WikiPage::doDeleteArticle ( reason,
suppress = false,
id = 0,
commit = true,
&$  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$idArticle ID
bool$commitDefaults to true, triggers transaction end
array&$errorArray of errors to append to
User$userThe deleting user
Returns:
bool True if successful

Definition at line 2735 of file WikiPage.php.

Referenced by WikiPageTest\testExists().

WikiPage::doDeleteArticleReal ( reason,
suppress = false,
id = 0,
commit = true,
&$  error = '',
User user = null 
)

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$idArticle ID
bool$commitDefaults to true, triggers transaction end
array&$errorArray of errors to append to
User$userThe deleting user
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 2759 of file WikiPage.php.

WikiPage::doDeleteUpdates ( id,
Content content = null 
)

Do some database updates after deletion.

Parameters:
int$idThe page_id value of the page being deleted
Content$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.

Definition at line 2903 of file WikiPage.php.

References DeferredUpdates\addUpdate(), getDeletionUpdates(), isCountable(), loadFromRow(), onArticleDelete(), LinksUpdate\queueRecursiveJobsForTable(), and DataUpdate\runUpdates().

WikiPage::doEdit ( text,
summary,
flags = 0,
baseRevId = false,
user = null 
)

Change an existing article or create a new article.

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

Parameters:
string$textNew text
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_DEFER_UPDATES Defer some of the updates until the end of index.php EDIT_AUTOSUMMARY Fill in blank summaries with generated text where possible

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
User$userThe user doing the edit
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.

Compatibility note: this function previously returned a boolean value indicating success/failure

Deprecated:
since 1.21: use doEditContent() instead.

Definition at line 1679 of file WikiPage.php.

WikiPage::doEditContent ( Content content,
summary,
flags = 0,
baseRevId = false,
User user = null,
serialisation_format = null 
)

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_DEFER_UPDATES Defer some of the updates until the end of index.php EDIT_AUTOSUMMARY Fill in blank summaries with generated text where possible

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
User$userThe user doing the edit
string$serialisation_formatFormat for storing the content in the database.
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

Definition at line 1738 of file WikiPage.php.

WikiPage::doEditUpdates ( Revision revision,
User user,
array options = array() 
)

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: boolean, whether the revision changed the content (default true)
  • created: boolean, whether the revision created the page (default false)
  • oldcountable: boolean or null (default null):
    • boolean: whether the page was counted as an article before that revision, only used in changed is true and created is false
    • null: don't change the article count

Definition at line 2167 of file WikiPage.php.

Perform the actions of a page purging.

Returns:
bool

Reimplemented in WikiFilePage.

Definition at line 1196 of file WikiPage.php.

WikiPage::doQuickEdit ( text,
User user,
comment = '',
minor = 0 
)

Edit an article without doing all that other stuff The article must already exist; link tables etc are not updated, caches are not flushed.

Parameters:
string$textText submitted
User$userThe relevant user
string$commentComment submitted
bool$minorWhereas it's a minor modification
Deprecated:
since 1.21, use doEditContent() instead.

Definition at line 2293 of file WikiPage.php.

WikiPage::doQuickEditContent ( Content content,
User user,
comment = '',
minor = false,
serialisation_format = null 
)

Edit an article without doing all that other stuff The article must already exist; link tables etc are not updated, caches are not flushed.

Parameters:
Content$contentContent submitted
User$userThe relevant user
string$commentComment submitted
bool$minorWhereas it's a minor modification
string$serialisation_formatFormat for storing the content in the database

Definition at line 2311 of file WikiPage.php.

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

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

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

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
Returns:
Status

Definition at line 2348 of file WikiPage.php.

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

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

Parameters:
User$userThe relevant user
int$oldidThe revision id being viewed. If not given or 0, latest revision is assumed.

Definition at line 1176 of file WikiPage.php.

Returns:
bool Whether or not the page exists in the database

Definition at line 451 of file WikiPage.php.

References loadPageData().

Referenced by hasViewableContent().

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 Object of the appropriate type

Definition at line 103 of file WikiPage.php.

References Title\getNamespace().

Referenced by ParserTest\addArticle(), SpecialMyLanguageTest\addDBData(), BackupDumperPageTest\addDBData(), TextPassDumperTest\addDBData(), EditPageTest\assertEdit(), Orphans\checkSeparation(), CleanupSpam\cleanupArticle(), UploadFromUrlTest\deleteFile(), ApiTestCaseUpload\deleteFileByTitle(), DifferenceEngineTest\doEdits(), ApiEditPage\execute(), CompareParserCache\execute(), ApiPurge\execute(), DeleteDefaultMessages\execute(), ApiRollback\execute(), ImportSiteScripts\execute(), Protect\execute(), AttachLatest\execute(), EditCLI\execute(), RollbackEdits\execute(), DeleteBatch\execute(), DeleteEqualMessages\execute(), ActionTest\getPage(), ListredirectsPage\getRedirectTarget(), ImportReporter\reportPage(), EditPageTest\testAutoMerge(), ApiQueryAllPagesTest\testBug25702(), ApiQueryRevisionsTest\testContentComesWithContentModelAndFormat(), TextContentTest\testDeletionUpdates(), ApiEditPageTest\testEdit_redirect(), ApiEditPageTest\testEdit_redirectText(), ApiEditPageTest\testEditConflict(), ApiEditPageTest\testEditConflict_bug41990(), ApiEditPageTest\testEditConflict_newSection(), ApiEditPageTest\testEditNewSection(), ApiEditPageTest\testEditSection(), WikitextContentTest\testGetSecondaryDataUpdates(), UploadFromUrlTest\testLeaveMessage(), ApiEditPageTest\testNonTextEdit(), RefreshLinksPartitionTest\testRefreshLinks(), TemplateCategoriesTest\testTemplateCategories(), ArticleTablesTest\testTemplatelinksUsesContentLanguage(), RequestContextTest\testWikiPageTitle(), and SpecialEditWatchlist\unwatchTitles().

static WikiPage::flattenRestrictions ( limit) [static, protected]

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

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

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

Definition at line 2616 of file WikiPage.php.

Returns overrides for action handlers.

Classes listed here will be used instead of the default one when (and only when) $wgActions[$action] === true. This allows subclasses to override the default behavior.

Todo:
Move this UI stuff somewhere else
Returns:
array

Definition at line 198 of file WikiPage.php.

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

static WikiPage::getAutosummary ( oldtext,
newtext,
flags 
) [static]

Return an applicable autosummary if one exists for the given edit.

Parameters:
string | null$oldtextThe previous text of the page.
string | null$newtextThe submitted text of the page.
int$flagsBitmask: a bitmask of flags submitted for the edit.
Returns:
string An appropriate autosummary, or an empty string.
Deprecated:
since 1.21, use ContentHandler::getAutosummary() instead

Definition at line 3303 of file WikiPage.php.

Get the cached timestamp for the last time the page changed.

This is only used to help handle slave lag by comparing to page_touched.

Returns:
string MW timestamp

Definition at line 823 of file WikiPage.php.

#@-

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

Returns:
TitleArray

Definition at line 3247 of file WikiPage.php.

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

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

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

Referenced by isCountable().

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

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

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

Returns:
int The view count for the page

Definition at line 473 of file WikiPage.php.

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

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:
array An array of DataUpdates objects

Definition at line 3529 of file WikiPage.php.

Referenced by doDeleteUpdates().

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

Returns:
int Page ID

Definition at line 441 of file WikiPage.php.

Referenced by getCategories(), and isCountable().

WikiPage::getLastNAuthors ( num,
revLatest = 0 
)

Get the last N authors.

Parameters:
int$numNumber of revisions to get
int | string$revLatestThe latest rev_id, selected from the master (optional)
Returns:
array Array of authors, duplicates not removed

Definition at line 1068 of file WikiPage.php.

Get the page_latest field.

Returns:
int The rev_id of current revision

Definition at line 559 of file WikiPage.php.

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

Get the page_links_updated field.

Returns:
string|null Containing GMT timestamp

Definition at line 548 of file WikiPage.php.

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

Returns:
bool Minor edit indicator for the last article revision.

Definition at line 809 of file WikiPage.php.

Get the Revision object of the oldest revision.

Returns:
Revision|null

Definition at line 570 of file WikiPage.php.

WikiPage::getParserOutput ( ParserOptions parserOptions,
oldid = null 
)

Get a ParserOutput for the given ParserOptions and revision ID.

The parser cache will be used if possible.

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)
Returns:
ParserOutput|bool ParserOutput or false if the revision was not found

Definition at line 1142 of file WikiPage.php.

Get the text of the current revision.

No side-effects...

Returns:
string|bool The text of the current revision. False on failure
Deprecated:
since 1.21, getContent() should be used instead.

Definition at line 703 of file WikiPage.php.

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

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

Get the latest revision.

Returns:
Revision|null

Definition at line 646 of file WikiPage.php.

References Revision\getTimestamp().

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

Get the text 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 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|bool The text of the current revision
Deprecated:
since 1.21, getContent() should be used instead.

Definition at line 687 of file WikiPage.php.

Referenced by getTimestamp().

Returns:
string MW timestamp of last article revision

Definition at line 712 of file WikiPage.php.

References ContentHandler\deprecated(), getText(), and Revision\RAW.

Get the title object of the article.

Returns:
Title Title object of this page

Definition at line 220 of file WikiPage.php.

Get the page_touched field.

Returns:
string Containing GMT timestamp

Definition at line 537 of file WikiPage.php.

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:
mixed String on success, false on failure
Since:
1.21 Before we had the Content object, this was done in getUndoText

Definition at line 1431 of file WikiPage.php.

WikiPage::getUndoText ( Revision undo,
Revision undoafter = null 
)

Get the text 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:
string|bool String on success, false on failure
Deprecated:
since 1.21: use ContentHandler::getUndoContent() instead.

Definition at line 1445 of file WikiPage.php.

Return a list of templates used by this article.

Uses the templatelinks table

Deprecated:
since 1.19; use Title::getTemplateLinksFrom()
Returns:
array Array of Title objects

Definition at line 3469 of file WikiPage.php.

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

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

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

References exists().

WikiPage::insertOn ( dbw)

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:
DatabaseBase$dbw
Returns:
int The newly created page_id key, or false if the title already existed

Definition at line 1248 of file WikiPage.php.

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

Insert an entry for this page into the redirect table.

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

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

Parameters:
Title$rtRedirect target

Definition at line 945 of file WikiPage.php.

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

Definition at line 849 of file WikiPage.php.

References $content, array(), getContent(), getId(), global, and wfGetDB().

Referenced by doDeleteUpdates().

WikiPage::isParserCacheUsed ( ParserOptions parserOptions,
oldid 
)

Should the parser cache be used?

Parameters:
ParserOptions$parserOptionsParserOptions to check
int$oldid
Returns:
bool

Definition at line 1121 of file WikiPage.php.

Tests if the article content represents a redirect.

Returns:
bool

Reimplemented in WikiFilePage.

Definition at line 486 of file WikiPage.php.

WikiPage::loadFromRow ( data,
from 
)

Load the object from a database row.

Since:
1.20
Parameters:
object$dataDatabase row containing at least fields returned by selectFields()
string | int$fromOne of the following:

Definition at line 400 of file WikiPage.php.

Referenced by doDeleteUpdates().

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

WikiPage::loadPageData ( from = 'fromdb')

Set the general counter, title etc data loaded from some source.

Parameters:
object | string | int$fromOne of the following:
Returns:
void

Definition at line 358 of file WikiPage.php.

Referenced by exists().

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

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:
Returns:
WikiPage|null

Definition at line 136 of file WikiPage.php.

Referenced by RefreshLinks\fixLinksFromArticle(), and RefreshLinks\fixRedirect().

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:
Returns:
WikiPage

Definition at line 162 of file WikiPage.php.

static WikiPage::onArticleCreate ( 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 3155 of file WikiPage.php.

static WikiPage::onArticleDelete ( title) [static]

Clears caches when article is deleted.

Parameters:
Title$title

Definition at line 3176 of file WikiPage.php.

Referenced by doDeleteUpdates().

static WikiPage::onArticleEdit ( title) [static]

Purge caches on page update etc.

Parameters:
Title$title
Todo:
Verify that $title is always a Title object (and never false or null), add Title hint to parameter $title.

Definition at line 3224 of file WikiPage.php.

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

Fetch a page record with the given conditions.

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

Definition at line 306 of file WikiPage.php.

Referenced by pageDataFromId().

WikiPage::pageDataFromId ( dbr,
id,
options = array() 
)

Fetch a page record matching the requested ID.

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

Definition at line 341 of file WikiPage.php.

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

WikiPage::pageDataFromTitle ( dbr,
title,
options = array() 
)

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

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

Definition at line 327 of file WikiPage.php.

WikiPage::prepareContentForEdit ( Content content,
revid = null,
User user = null,
serialization_format = null 
)

Prepare content which is about to be saved.

Returns a stdclass with source, pst and output members

Parameters:
Content$content
int | null$revid
User | null$user
string | null$serialization_format
Returns:
bool|object
Since:
1.21

Definition at line 2101 of file WikiPage.php.

WikiPage::prepareTextForEdit ( text,
revid = null,
User user = null 
)

Prepare text which is about to be saved.

Returns a stdclass with source, pst and output members

Deprecated:
since 1.21: use prepareContentForEdit instead.
Returns:
object

Definition at line 2082 of file WikiPage.php.

WikiPage::preSaveTransform ( text,
User user = null,
ParserOptions popts = null 
)

This function is called right before saving the wikitext, so we can do things like signatures and links-in-context.

Deprecated:
since 1.19; use Parser::preSaveTransform() instead
Parameters:
string$textArticle contents
User$userUser doing the edit
ParserOptions$poptsParser options, default options for the user loaded if null given
Returns:
string Article contents with altered wikitext markup (signatures converted, {{subst:}}, templates, etc.)

Definition at line 3485 of file WikiPage.php.

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

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

WikiPage::replaceSection ( sectionId,
text,
sectionTitle = '',
edittime = null 
)
Parameters:
string | number | 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.
string$textNew text 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:
string New complete article text, or null if error.
Deprecated:
since 1.21, use replaceSectionAtRev() instead

Definition at line 1481 of file WikiPage.php.

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

Definition at line 1564 of file WikiPage.php.

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

Definition at line 1534 of file WikiPage.php.

static WikiPage::selectFields ( ) [static]

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

Returns:
array

Definition at line 270 of file WikiPage.php.

Set the cached timestamp for the last time the page changed.

This is only used to help handle slave lag by comparing to page_touched.

Parameters:
string$timestamp
Returns:
void

Definition at line 835 of file WikiPage.php.

WikiPage::setLastEdit ( Revision revision) [protected]

Set the latest revision.

Parameters:
Revision$revision

Definition at line 637 of file WikiPage.php.

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

Parameters:
string$tsMW timestamp of last article revision
Returns:
void

Definition at line 726 of file WikiPage.php.

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

WikiPage::updateCategoryCounts ( array added,
array deleted 
)

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

Parameters:
array$addedThe names of categories that were added
array$deletedThe names of categories that were deleted

Definition at line 3334 of file WikiPage.php.

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:
DatabaseBase$dbw
Revision$revision
Returns:
bool

Definition at line 1391 of file WikiPage.php.

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

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

Parameters:
DatabaseBase$dbw
Title$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:
private

Definition at line 1354 of file WikiPage.php.

WikiPage::updateRestrictions ( limit = array(),
reason = '',
&$  cascade = 0,
expiry = array(),
User user = null 
)

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

Deprecated:
since 1.19
Parameters:
array$limitSet of restriction keys
string$reason
int&$cascadeSet to false if cascading protection isn't allowed.
array$expiryPer restriction type expiration
User$userThe user updating the restrictions
Returns:
bool True on success

Definition at line 3510 of file WikiPage.php.

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

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

Parameters:
DatabaseBase$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 True on success, false on failure

Definition at line 1291 of file WikiPage.php.


Member Data Documentation

int null WikiPage::$mCounter = null [protected]

Definition at line 85 of file WikiPage.php.

WikiPage::$mDataLoaded = false

{

Access:
protected

Definition at line 47 of file WikiPage.php.

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

One of the READ_* constants.

Definition at line 61 of file WikiPage.php.

int WikiPage::$mId = null [protected]

Definition at line 57 of file WikiPage.php.

WikiPage::$mIsRedirect = false

{

Access:
protected

Definition at line 48 of file WikiPage.php.

Revision WikiPage::$mLastRevision = null [protected]

Definition at line 69 of file WikiPage.php.

WikiPage::$mLatest = false

{

Access:
protected

Definition at line 49 of file WikiPage.php.

string WikiPage::$mLinksUpdated = '19700101000000' [protected]

Definition at line 81 of file WikiPage.php.

WikiPage::$mPreparedEdit = false

Definition at line 53 of file WikiPage.php.

Title WikiPage::$mRedirectTarget = null [protected]

Definition at line 65 of file WikiPage.php.

string WikiPage::$mTimestamp = '' [protected]

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

Definition at line 73 of file WikiPage.php.

Title WikiPage::$mTitle = null

Definition at line 42 of file WikiPage.php.

string WikiPage::$mTouched = '19700101000000' [protected]

Definition at line 77 of file WikiPage.php.


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