protected $mId = null;
/**
- * @var int; one of the READ_* constants
+ * @var int One of the READ_* constants
*/
protected $mDataLoadedFrom = self::READ_NONE;
protected $mLastRevision = null;
/**
- * @var string; timestamp of the current revision or empty string if not loaded
+ * @var string Timestamp of the current revision or empty string if not loaded
*/
protected $mTimestamp = '';
/**
* Constructor and clear the article
- * @param $title Title Reference to a Title object.
+ * @param Title $title Reference to a Title object.
*/
public function __construct( Title $title ) {
$this->mTitle = $title;
/**
* Constructor from a page id
*
- * @param int $id article ID to load
- * @param string|int $from one of the following values:
+ * @param int $id Article ID to load
+ * @param string|int $from One of the following values:
* - "fromdb" or WikiPage::READ_NORMAL to select from a slave database
* - "fromdbmaster" or WikiPage::READ_LATEST to select from the master database
*
* Constructor from a database row
*
* @since 1.20
- * @param $row object: database row containing at least fields returned
- * by selectFields().
- * @param string|int $from source of $data:
+ * @param object $row Database row containing at least fields returned by selectFields().
+ * @param string|int $from Source of $data:
* - "fromdb" or WikiPage::READ_NORMAL: from a slave DB
* - "fromdbmaster" or WikiPage::READ_LATEST: from the master DB
* - "forupdate" or WikiPage::READ_LOCKING: from the master DB using SELECT FOR UPDATE
/**
* Convert 'fromdb', 'fromdbmaster' and 'forupdate' to READ_* constants.
*
- * @param $type object|string|int
+ * @param object|string|int $type
* @return mixed
*/
private static function convertSelectType( $type ) {
*
* @todo Move this UI stuff somewhere else
*
- * @return Array
+ * @return array
*/
public function getActionOverrides() {
$content_handler = $this->getContentHandler();
/**
* Get the title object of the article
- * @return Title object of this page
+ * @return Title Title object of this page
*/
public function getTitle() {
return $this->mTitle;
/**
* Fetch a page record with the given conditions
- * @param $dbr DatabaseBase object
- * @param $conditions Array
- * @param $options Array
- * @return mixed Database result resource, or false on failure
+ * @param DatabaseBase $dbr
+ * @param array $conditions
+ * @param array $options
+ * @return object|bool Database result resource, or false on failure
*/
protected function pageData( $dbr, $conditions, $options = array() ) {
$fields = self::selectFields();
* Fetch a page record matching the Title object's namespace and title
* using a sanitized title string
*
- * @param $dbr DatabaseBase object
- * @param $title Title object
- * @param $options Array
- * @return mixed Database result resource, or false on failure
+ * @param DatabaseBase $dbr
+ * @param Title $title
+ * @param array $options
+ * @return object|bool Database result resource, or false on failure
*/
public function pageDataFromTitle( $dbr, $title, $options = array() ) {
return $this->pageData( $dbr, array(
/**
* Fetch a page record matching the requested ID
*
- * @param $dbr DatabaseBase
- * @param $id Integer
- * @param $options Array
- * @return mixed Database result resource, or false on failure
+ * @param DatabaseBase $dbr
+ * @param int $id
+ * @param array $options
+ * @return object|bool Database result resource, or false on failure
*/
public function pageDataFromId( $dbr, $id, $options = array() ) {
return $this->pageData( $dbr, array( 'page_id' => $id ), $options );
* Set the general counter, title etc data loaded from
* some source.
*
- * @param $from object|string|int One of the following:
+ * @param object|string|int $from One of the following:
* - A DB query result object
* - "fromdb" or WikiPage::READ_NORMAL to get from a slave DB
* - "fromdbmaster" or WikiPage::READ_LATEST to get from the master DB
* Load the object from a database row
*
* @since 1.20
- * @param $data object: database row containing at least fields returned
- * by selectFields()
+ * @param object $data Database row containing at least fields returned by selectFields()
* @param string|int $from One of the following:
* - "fromdb" or WikiPage::READ_NORMAL if the data comes from a slave DB
* - "fromdbmaster" or WikiPage::READ_LATEST if the data comes from the master DB
* Will use the revisions actual content model if the page exists,
* and the page's default if the page doesn't exist yet.
*
- * @return String
+ * @return string
*
* @since 1.21
*/
/**
* Loads page_touched and returns a value indicating if it should be used
- * @return boolean true if not a redirect
+ * @return bool true if not a redirect
*/
public function checkTouched() {
if ( !$this->mDataLoaded ) {
/**
* Get the page_touched field
- * @return string containing GMT timestamp
+ * @return string Containing GMT timestamp
*/
public function getTouched() {
if ( !$this->mDataLoaded ) {
/**
* Get the page_links_updated field
- * @return string|null containing GMT timestamp
+ * @return string|null Containing GMT timestamp
*/
public function getLinksTimestamp() {
if ( !$this->mDataLoaded ) {
/**
* Get the page_latest field
- * @return integer rev_id of current revision
+ * @return int rev_id of current revision
*/
public function getLatest() {
if ( !$this->mDataLoaded ) {
/**
* Set the latest revision
+ * @param Revision $revision
*/
protected function setLastEdit( Revision $revision ) {
$this->mLastRevision = $revision;
/**
* Get the content of the current revision. No side-effects...
*
- * @param $audience Integer: one 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
- * @param $user User object to check for, only if FOR_THIS_USER is passed
- * to the $audience parameter
+ * @param int $audience int One 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
+ * @param User $user User object to check for, only if FOR_THIS_USER is passed
+ * to the $audience parameter
* @return Content|null The content of the current revision
*
* @since 1.21
/**
* Get the text of the current revision. No side-effects...
*
- * @param $audience Integer: one 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
- * @param $user User object to check for, only if FOR_THIS_USER is passed
- * to the $audience parameter
- * @return String|false The text of the current revision
- * @deprecated as of 1.21, getContent() should be used instead.
+ * @param int $audience One 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
+ * @param User $user User object to check for, only if FOR_THIS_USER is passed
+ * to the $audience parameter
+ * @return string|bool The text of the current revision
+ * @deprecated since 1.21, getContent() should be used instead.
*/
public function getText( $audience = Revision::FOR_PUBLIC, User $user = null ) { // @todo deprecated, replace usage!
ContentHandler::deprecated( __METHOD__, '1.21' );
/**
* Get the text of the current revision. No side-effects...
*
- * @return String|bool The text of the current revision. False on failure
- * @deprecated as of 1.21, getContent() should be used instead.
+ * @return string|bool The text of the current revision. False on failure
+ * @deprecated since 1.21, getContent() should be used instead.
*/
public function getRawText() {
ContentHandler::deprecated( __METHOD__, '1.21' );
}
/**
- * @param $audience Integer: one 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
- * @param $user User object to check for, only if FOR_THIS_USER is passed
- * to the $audience parameter
+ * @param int $audience One 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
+ * @param User $user User object to check for, only if FOR_THIS_USER is passed
+ * to the $audience parameter
* @return int user ID for the user that made the last article revision
*/
public function getUser( $audience = Revision::FOR_PUBLIC, User $user = null ) {
/**
* Get the User object of the user who created the page
- * @param $audience Integer: one 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
- * @param $user User object to check for, only if FOR_THIS_USER is passed
- * to the $audience parameter
+ * @param int $audience One 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
+ * @param User $user User object to check for, only if FOR_THIS_USER is passed
+ * to the $audience parameter
* @return User|null
*/
public function getCreator( $audience = Revision::FOR_PUBLIC, User $user = null ) {
}
/**
- * @param $audience Integer: one 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
- * @param $user User object to check for, only if FOR_THIS_USER is passed
- * to the $audience parameter
+ * @param int $audience One 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
+ * @param User $user User object to check for, only if FOR_THIS_USER is passed
+ * to the $audience parameter
* @return string username of the user that made the last article revision
*/
public function getUserText( $audience = Revision::FOR_PUBLIC, User $user = null ) {
}
/**
- * @param $audience Integer: one 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
- * @param $user User object to check for, only if FOR_THIS_USER is passed
- * to the $audience parameter
+ * @param int $audience One 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
+ * @param User $user User object to check for, only if FOR_THIS_USER is passed
+ * to the $audience parameter
* @return string Comment stored for the last article revision
*/
public function getComment( $audience = Revision::FOR_PUBLIC, User $user = null ) {
/**
* Returns true if last revision was marked as "minor edit"
*
- * @return boolean Minor edit indicator for the last article revision.
+ * @return bool Minor edit indicator for the last article revision.
*/
public function getMinorEdit() {
$this->loadLastEdit();
/**
* 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.
- * @param $timestamp string
+ * @param string $timestamp
* @return void
*/
public function setCachedLastEditTime( $timestamp ) {
* Determine whether a page would be suitable for being counted as an
* article in the site_stats table based on the title & its content
*
- * @param $editInfo Object|bool (false): object returned by prepareTextForEdit(),
- * if false, the current database state will be used
- * @return Boolean
+ * @param object|bool $editInfo (false): object returned by prepareTextForEdit(),
+ * if false, the current database state will be used
+ * @return bool
*/
public function isCountable( $editInfo = false ) {
global $wgArticleCountMethod;
*
* The target will be fetched from the redirect table if possible.
* If this page doesn't have an entry there, call insertRedirect()
- * @return Title|mixed object, or null if this page is not a redirect
+ * @return Title|null Title object, or null if this page is not a redirect
*/
public function getRedirectTarget() {
if ( !$this->mTitle->isRedirect() ) {
* Insert an entry for this page into the redirect table.
*
* Don't call this function directly unless you know what you're doing.
- * @return Title object or null if not a redirect
+ * @return Title|null Title object or null if not a redirect
*/
public function insertRedirect() {
// recurse through to only get the final target
/**
* Insert or update the redirect table entry for this page to indicate
* it redirects to $rt .
- * @param $rt Title redirect target
+ * @param Title $rt Redirect target
*/
public function insertRedirectEntry( $rt ) {
$dbw = wfGetDB( DB_MASTER );
/**
* Get the Title object or URL this page redirects to
*
- * @return mixed false, Title of in-wiki target, or string with URL
+ * @return bool|Title|string false, Title of in-wiki target, or string with URL
*/
public function followRedirect() {
return $this->getRedirectURL( $this->getRedirectTarget() );
* 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.
- * @param $rt Title Redirect target
- * @return mixed false, Title object of local target, or string with URL
+ * @param Title $rt Redirect target
+ * @return bool|Title|string false, Title object of local target, or string with URL
*/
public function getRedirectURL( $rt ) {
if ( !$rt ) {
/**
* Get the last N authors
* @param int $num Number of revisions to get
- * @param int|string $revLatest the latest rev_id, selected from the master (optional)
+ * @param int|string $revLatest The latest rev_id, selected from the master (optional)
* @return array Array of authors, duplicates not removed
*/
public function getLastNAuthors( $num, $revLatest = 0 ) {
/**
* Should the parser cache be used?
*
- * @param $parserOptions ParserOptions to check
- * @param $oldid int
- * @return boolean
+ * @param ParserOptions $parserOptions ParserOptions to check
+ * @param int $oldid
+ * @return bool
*/
public function isParserCacheUsed( ParserOptions $parserOptions, $oldid ) {
global $wgEnableParserCache;
* @since 1.19
* @param ParserOptions $parserOptions ParserOptions to use for the parse operation
* @param null|int $oldid Revision ID to get the text from, passing null or 0 will
- * get the current revision (default value)
+ * get the current revision (default value)
*
- * @return ParserOutput or false if the revision was not found
+ * @return ParserOutput|bool ParserOutput or false if the revision was not found
*/
public function getParserOutput( ParserOptions $parserOptions, $oldid = null ) {
wfProfileIn( __METHOD__ );
* or else the record will be left in a funky state.
* Best if all done inside a transaction.
*
- * @param $dbw DatabaseBase
+ * @param DatabaseBase $dbw
* @return int The newly created page_id key, or false if the title already existed
*/
public function insertOn( $dbw ) {
/**
* Update the page record to point to a newly saved revision.
*
- * @param $dbw DatabaseBase: object
- * @param $revision Revision: For ID number, and text used to set
- * length and redirect status fields
- * @param $lastRevision Integer: if 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.
- * @param $lastRevIsRedirect Boolean: if given, will optimize adding and
- * removing rows in redirect table.
+ * @param DatabaseBase $dbw
+ * @param Revision $revision For ID number, and text used to set
+ * length and redirect status fields
+ * @param int $lastRevision If 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.
+ * @param bool $lastRevIsRedirect If given, will optimize adding and
+ * removing rows in redirect table.
* @return bool true on success, false on failure
* @private
*/
/**
* Add row to the redirect table if this is a redirect, remove otherwise.
*
- * @param $dbw DatabaseBase
- * @param $redirectTitle Title object pointing to the redirect target,
- * or NULL if this is not a redirect
- * @param $lastRevIsRedirect null|bool If given, will optimize adding and
- * removing rows in redirect table.
+ * @param DatabaseBase $dbw
+ * @param Title $redirectTitle Title object pointing to the redirect target,
+ * or NULL if this is not a redirect
+ * @param null|bool $lastRevIsRedirect If given, will optimize adding and
+ * removing rows in redirect table.
* @return bool true on success, false on failure
* @private
*/
* If the given revision is newer than the currently set page_latest,
* update the page record. Otherwise, do nothing.
*
- * @param $dbw DatabaseBase object
- * @param $revision Revision object
- * @return mixed
+ * @param DatabaseBase $dbw
+ * @param Revision $revision
+ * @return bool
*/
public function updateIfNewerOn( $dbw, $revision ) {
wfProfileIn( __METHOD__ );
* 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
- * @param $undo Revision
- * @param $undoafter Revision Must be an earlier revision than $undo
+ * @param Revision $undo
+ * @param Revision $undoafter Must be an earlier revision than $undo
* @return mixed string on success, false on failure
* @since 1.21
* Before we had the Content object, this was done in getUndoText
* 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
- * @param $undo Revision
- * @param $undoafter Revision Must be an earlier revision than $undo
- * @return mixed string on success, false on failure
+ * @param Revision $undo
+ * @param Revision $undoafter Must be an earlier revision than $undo
+ * @return string|bool string on success, false on failure
* @deprecated since 1.21: use ContentHandler::getUndoContent() instead.
*/
public function getUndoText( Revision $undo, Revision $undoafter = null ) {
}
/**
- * @param mixed $section Null/false, a section number (0, 1, 2, T1, T2, ...) or "new".
+ * @param string|null|bool $section Null/false, a section number (0, 1, 2, T1, T2, ...) or "new".
* @param string $text New text of the section.
* @param string $sectionTitle New section's subject, only if $section is "new".
* @param string $edittime Revision timestamp or null to use the current revision.
}
/**
- * @param mixed $section Null/false, a section number (0, 1, 2, T1, T2, ...) or "new".
+ * @param string|null|bool $section Null/false, a section number (0, 1, 2, T1, T2, ...) or "new".
* @param Content $sectionContent New content of the section.
* @param string $sectionTitle New section's subject, only if $section is "new".
* @param string $edittime Revision timestamp or null to use the current revision.
/**
* Check flags and add EDIT_NEW or EDIT_UPDATE to them as needed.
- * @param $flags Int
- * @return Int updated $flags
+ * @param int $flags
+ * @return int Updated $flags
*/
public function checkFlags( $flags ) {
if ( !( $flags & EDIT_NEW ) && !( $flags & EDIT_UPDATE ) ) {
* Change an existing article or create a new article. Updates RC and all necessary caches,
* optionally via the deferred update array.
*
- * @param string $text new text
- * @param string $summary edit summary
- * @param $flags Integer bitfield:
+ * @param string $text New text
+ * @param string $summary Edit summary
+ * @param int $flags Bitfield:
* EDIT_NEW
* Article is known or assumed to be non-existent, create a new one
* EDIT_UPDATE
* edit-already-exists error will be returned. These two conditions are also possible with
* auto-detection due to MediaWiki's performance-optimised locking strategy.
*
- * @param bool|int $baseRevId int the revision ID this edit was based off, if any
- * @param $user User the user doing the edit
+ * @param bool|int $baseRevId The revision ID this edit was based off, if any
+ * @param User $user The user doing the edit
*
* @throws MWException
* @return Status object. Possible errors:
* Change an existing article or create a new article. Updates RC and all necessary caches,
* optionally via the deferred update array.
*
- * @param $content Content: new content
- * @param string $summary edit summary
- * @param $flags Integer bitfield:
+ * @param Content $content New content
+ * @param string $summary Edit summary
+ * @param int $flags Bitfield:
* EDIT_NEW
* Article is known or assumed to be non-existent, create a new one
* EDIT_UPDATE
* edit-already-exists error will be returned. These two conditions are also possible with
* auto-detection due to MediaWiki's performance-optimised locking strategy.
*
- * @param bool|int $baseRevId the revision ID this edit was based off, if any
- * @param $user User the user doing the edit
- * @param $serialisation_format String: format for storing the content in the database
+ * @param bool|int $baseRevId The revision ID this edit was based off, if any
+ * @param User $user The user doing the edit
+ * @param string $serialisation_format Format for storing the content in the database
*
* @throws MWException
* @return Status object. Possible errors:
}
$dbw->begin( __METHOD__ );
+ try {
- $prepStatus = $content->prepareSave( $this, $flags, $baseRevId, $user );
- $status->merge( $prepStatus );
+ $prepStatus = $content->prepareSave( $this, $flags, $baseRevId, $user );
+ $status->merge( $prepStatus );
- if ( !$status->isOK() ) {
- $dbw->rollback( __METHOD__ );
+ if ( !$status->isOK() ) {
+ $dbw->rollback( __METHOD__ );
- wfProfileOut( __METHOD__ );
- return $status;
- }
-
- $revisionId = $revision->insertOn( $dbw );
+ wfProfileOut( __METHOD__ );
+ return $status;
+ }
+ $revisionId = $revision->insertOn( $dbw );
- // Update page
- //
- // Note that we use $this->mLatest instead of fetching a value from the master DB
- // during the course of this function. This makes sure that EditPage can detect
- // edit conflicts reliably, either by $ok here, or by $article->getTimestamp()
- // before this function is called. A previous function used a separate query, this
- // creates a window where concurrent edits can cause an ignored edit conflict.
- $ok = $this->updateRevisionOn( $dbw, $revision, $oldid, $oldIsRedirect );
+ // Update page
+ //
+ // Note that we use $this->mLatest instead of fetching a value from the master DB
+ // during the course of this function. This makes sure that EditPage can detect
+ // edit conflicts reliably, either by $ok here, or by $article->getTimestamp()
+ // before this function is called. A previous function used a separate query, this
+ // creates a window where concurrent edits can cause an ignored edit conflict.
+ $ok = $this->updateRevisionOn( $dbw, $revision, $oldid, $oldIsRedirect );
- if ( !$ok ) {
- // Belated edit conflict! Run away!!
- $status->fatal( 'edit-conflict' );
+ if ( !$ok ) {
+ // Belated edit conflict! Run away!!
+ $status->fatal( 'edit-conflict' );
- $dbw->rollback( __METHOD__ );
+ $dbw->rollback( __METHOD__ );
- wfProfileOut( __METHOD__ );
- return $status;
- }
+ wfProfileOut( __METHOD__ );
+ return $status;
+ }
- wfRunHooks( 'NewRevisionFromEditComplete', array( $this, $revision, $baseRevId, $user ) );
- // Update recentchanges
- if ( !( $flags & EDIT_SUPPRESS_RC ) ) {
- // Mark as patrolled if the user can do so
- $patrolled = $wgUseRCPatrol && !count(
+ wfRunHooks( 'NewRevisionFromEditComplete', array( $this, $revision, $baseRevId, $user ) );
+ // Update recentchanges
+ if ( !( $flags & EDIT_SUPPRESS_RC ) ) {
+ // Mark as patrolled if the user can do so
+ $patrolled = $wgUseRCPatrol && !count(
$this->mTitle->getUserPermissionsErrors( 'autopatrol', $user ) );
- // Add RC row to the DB
- $rc = RecentChange::notifyEdit( $now, $this->mTitle, $isminor, $user, $summary,
- $oldid, $this->getTimestamp(), $bot, '', $oldsize, $newsize,
- $revisionId, $patrolled
- );
+ // Add RC row to the DB
+ $rc = RecentChange::notifyEdit( $now, $this->mTitle, $isminor, $user, $summary,
+ $oldid, $this->getTimestamp(), $bot, '', $oldsize, $newsize,
+ $revisionId, $patrolled
+ );
- // Log auto-patrolled edits
- if ( $patrolled ) {
- PatrolLog::record( $rc, true, $user );
+ // Log auto-patrolled edits
+ if ( $patrolled ) {
+ PatrolLog::record( $rc, true, $user );
+ }
}
+ $user->incEditCount();
+ } catch ( MWException $e ) {
+ $dbw->rollback( __METHOD__ );
+ // Question: Would it perhaps be better if this method turned all
+ // exceptions into $status's?
+ throw $e;
}
- $user->incEditCount();
$dbw->commit( __METHOD__ );
} else {
// Bug 32948: revision ID must be set to page {{REVISIONID}} and
$status->value['new'] = true;
$dbw->begin( __METHOD__ );
+ try {
- $prepStatus = $content->prepareSave( $this, $flags, $baseRevId, $user );
- $status->merge( $prepStatus );
+ $prepStatus = $content->prepareSave( $this, $flags, $baseRevId, $user );
+ $status->merge( $prepStatus );
- if ( !$status->isOK() ) {
- $dbw->rollback( __METHOD__ );
+ if ( !$status->isOK() ) {
+ $dbw->rollback( __METHOD__ );
- wfProfileOut( __METHOD__ );
- return $status;
- }
+ wfProfileOut( __METHOD__ );
+ return $status;
+ }
- $status->merge( $prepStatus );
+ $status->merge( $prepStatus );
- // Add the page record; stake our claim on this title!
- // This will return false if the article already exists
- $newid = $this->insertOn( $dbw );
+ // Add the page record; stake our claim on this title!
+ // This will return false if the article already exists
+ $newid = $this->insertOn( $dbw );
- if ( $newid === false ) {
- $dbw->rollback( __METHOD__ );
- $status->fatal( 'edit-already-exists' );
+ if ( $newid === false ) {
+ $dbw->rollback( __METHOD__ );
+ $status->fatal( 'edit-already-exists' );
- wfProfileOut( __METHOD__ );
- return $status;
- }
+ wfProfileOut( __METHOD__ );
+ return $status;
+ }
- // Save the revision text...
- $revision = new Revision( array(
- 'page' => $newid,
- 'title' => $this->getTitle(), // for determining the default content model
- 'comment' => $summary,
- 'minor_edit' => $isminor,
- 'text' => $serialized,
- 'len' => $newsize,
- 'user' => $user->getId(),
- 'user_text' => $user->getName(),
- 'timestamp' => $now,
- 'content_model' => $content->getModel(),
- 'content_format' => $serialisation_format,
- ) );
- $revisionId = $revision->insertOn( $dbw );
+ // Save the revision text...
+ $revision = new Revision( array(
+ 'page' => $newid,
+ 'title' => $this->getTitle(), // for determining the default content model
+ 'comment' => $summary,
+ 'minor_edit' => $isminor,
+ 'text' => $serialized,
+ 'len' => $newsize,
+ 'user' => $user->getId(),
+ 'user_text' => $user->getName(),
+ 'timestamp' => $now,
+ 'content_model' => $content->getModel(),
+ 'content_format' => $serialisation_format,
+ ) );
+ $revisionId = $revision->insertOn( $dbw );
- // Bug 37225: use accessor to get the text as Revision may trim it
- $content = $revision->getContent(); // sanity; get normalized version
+ // Bug 37225: use accessor to get the text as Revision may trim it
+ $content = $revision->getContent(); // sanity; get normalized version
- if ( $content ) {
- $newsize = $content->getSize();
- }
+ if ( $content ) {
+ $newsize = $content->getSize();
+ }
- // Update the page record with revision data
- $this->updateRevisionOn( $dbw, $revision, 0 );
+ // Update the page record with revision data
+ $this->updateRevisionOn( $dbw, $revision, 0 );
- wfRunHooks( 'NewRevisionFromEditComplete', array( $this, $revision, false, $user ) );
+ wfRunHooks( 'NewRevisionFromEditComplete', array( $this, $revision, false, $user ) );
- // Update recentchanges
- if ( !( $flags & EDIT_SUPPRESS_RC ) ) {
- // Mark as patrolled if the user can do so
- $patrolled = ( $wgUseRCPatrol || $wgUseNPPatrol ) && !count(
- $this->mTitle->getUserPermissionsErrors( 'autopatrol', $user ) );
- // Add RC row to the DB
- $rc = RecentChange::notifyNew( $now, $this->mTitle, $isminor, $user, $summary, $bot,
- '', $newsize, $revisionId, $patrolled );
+ // Update recentchanges
+ if ( !( $flags & EDIT_SUPPRESS_RC ) ) {
+ // Mark as patrolled if the user can do so
+ $patrolled = ( $wgUseRCPatrol || $wgUseNPPatrol ) && !count(
+ $this->mTitle->getUserPermissionsErrors( 'autopatrol', $user ) );
+ // Add RC row to the DB
+ $rc = RecentChange::notifyNew( $now, $this->mTitle, $isminor, $user, $summary, $bot,
+ '', $newsize, $revisionId, $patrolled );
- // Log auto-patrolled edits
- if ( $patrolled ) {
- PatrolLog::record( $rc, true, $user );
+ // Log auto-patrolled edits
+ if ( $patrolled ) {
+ PatrolLog::record( $rc, true, $user );
+ }
}
+ $user->incEditCount();
+
+ } catch ( MWException $e ) {
+ $dbw->rollback( __METHOD__ );
+ throw $e;
}
- $user->incEditCount();
$dbw->commit( __METHOD__ );
// Update links, etc.
* Prepare text which is about to be saved.
* Returns a stdclass with source, pst and output members
*
- * @deprecated in 1.21: use prepareContentForEdit instead.
+ * @deprecated since 1.21: use prepareContentForEdit instead.
+ * @return object
*/
public function prepareTextForEdit( $text, $revid = null, User $user = null ) {
ContentHandler::deprecated( __METHOD__, '1.21' );
$edit = (object)array();
$edit->revid = $revid;
+ $edit->timestamp = wfTimestampNow();
$edit->pstContent = $content ? $content->preSaveTransform( $this->mTitle, $user, $popts ) : null;
* Purges pages that include this page if the text was changed here.
* Every 100th edit, prune the recent changes table.
*
- * @param $revision Revision object
- * @param $user User object that did the revision
- * @param array $options of options, following indexes are used:
+ * @param Revision $revision
+ * @param User $user User object that did the revision
+ * @param array $options Array 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):
// Save it to the parser cache
if ( $wgEnableParserCache ) {
$parserCache = ParserCache::singleton();
- $parserCache->save( $editInfo->output, $this, $editInfo->popts );
+ $parserCache->save(
+ $editInfo->output, $this, $editInfo->popts, $editInfo->timestamp, $editInfo->revid
+ );
}
// Update the links tables and other secondary data
if ( !$options['changed'] ) {
$good = 0;
- $total = 0;
} elseif ( $options['created'] ) {
$good = (int)$this->isCountable( $editInfo );
- $total = 1;
} elseif ( $options['oldcountable'] !== null ) {
$good = (int)$this->isCountable( $editInfo ) - (int)$options['oldcountable'];
- $total = 0;
} else {
$good = 0;
- $total = 0;
}
+ $edits = $options['changed'] ? 1 : 0;
+ $total = $options['created'] ? 1 : 0;
- DeferredUpdates::addUpdate( new SiteStatsUpdate( 0, 1, $good, $total ) );
+ DeferredUpdates::addUpdate( new SiteStatsUpdate( 0, $edits, $good, $total ) );
DeferredUpdates::addUpdate( new SearchUpdate( $id, $title, $content ) );
// If this is another user's talk page, update newtalk.
if ( $options['created'] ) {
self::onArticleCreate( $this->mTitle );
- } else {
+ } elseif ( $options['changed'] ) { // bug 50785
self::onArticleEdit( $this->mTitle );
}
* The article must already exist; link tables etc
* are not updated, caches are not flushed.
*
- * @param string $text text submitted
- * @param $user User The relevant user
- * @param string $comment comment submitted
- * @param $minor Boolean: whereas it's a minor modification
+ * @param string $text Text submitted
+ * @param User $user The relevant user
+ * @param string $comment Comment submitted
+ * @param bool $minor Whereas it's a minor modification
*
* @deprecated since 1.21, use doEditContent() instead.
*/
$revision = new Revision( array(
'title' => $this->getTitle(), // for determining the default content model
'page' => $this->getId(),
+ 'user_text' => $user->getName(),
+ 'user' => $user->getId(),
'text' => $serialized,
'length' => $content->getSize(),
'comment' => $comment,
* Update the article's restriction field, and leave a log entry.
* This works for protection both existing and non-existing pages.
*
- * @param array $limit set of restriction keys
- * @param array $expiry per restriction type expiration
+ * @param array $limit Set of restriction keys
+ * @param array $expiry Per restriction type expiration
* @param int &$cascade Set to false if cascading protection isn't allowed.
* @param string $reason
* @param User $user The user updating the restrictions
// insert null revision to identify the page protection change as edit summary
$latest = $this->getLatest();
- $nullRevision = $this->insertProtectNullRevision( $revCommentMsg, $limit, $expiry, $cascade, $reason );
+ $nullRevision = $this->insertProtectNullRevision( $revCommentMsg, $limit, $expiry, $cascade, $reason, $user );
if ( $nullRevision === null ) {
return Status::newFatal( 'no-null-revision', $this->mTitle->getPrefixedText() );
}
/**
* Insert a new null revision for this page.
*
- * @param string $revCommentMsg comment message key for the revision
- * @param array $limit set of restriction keys
- * @param array $expiry per restriction type expiration
+ * @param string $revCommentMsg Comment message key for the revision
+ * @param array $limit Set of restriction keys
+ * @param array $expiry Per restriction type expiration
* @param int $cascade Set to false if cascading protection isn't allowed.
* @param string $reason
- * @return Revision|null on error
+ * @param User|null $user
+ * @return Revision|null Null on error
*/
- public function insertProtectNullRevision( $revCommentMsg, array $limit, array $expiry, $cascade, $reason ) {
+ public function insertProtectNullRevision( $revCommentMsg, array $limit, array $expiry, $cascade, $reason, $user = null ) {
global $wgContLang;
$dbw = wfGetDB( DB_MASTER );
)->inContentLanguage()->text();
}
- $nullRev = Revision::newNullRevision( $dbw, $this->getId(), $editComment, true );
+ $nullRev = Revision::newNullRevision( $dbw, $this->getId(), $editComment, true, $user );
if ( $nullRev ) {
$nullRev->insertOn( $dbw );
/**
* Builds the description to serve as comment for the edit.
*
- * @param array $limit set of restriction keys
- * @param array $expiry per restriction type expiration
+ * @param array $limit Set of restriction keys
+ * @param array $expiry Per restriction type expiration
* @return string
*/
public function protectDescription( array $limit, array $expiry ) {
* 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.
*
- * @param array $limit set of restriction keys
- * @param array $expiry per restriction type expiration
+ * @param array $limit Set of restriction keys
+ * @param array $expiry Per restriction type expiration
* @return string
*/
public function protectDescriptionLog( array $limit, array $expiry ) {
*
* Deletes the article with database consistency, writes logs, purges caches
*
- * @param string $reason delete reason for deletion log
- * @param $suppress boolean suppress all revisions and log the deletion in
+ * @param string $reason Delete reason for deletion log
+ * @param bool $suppress Suppress all revisions and log the deletion in
* the suppression log instead of the deletion log
- * @param int $id article ID
- * @param $commit boolean defaults to true, triggers transaction end
- * @param &$error Array of errors to append to
- * @param $user User The deleting user
- * @return boolean true if successful
+ * @param int $id Article ID
+ * @param bool $commit Defaults to true, triggers transaction end
+ * @param array &$error Array of errors to append to
+ * @param User $user The deleting user
+ * @return bool true if successful
*/
public function doDeleteArticle(
$reason, $suppress = false, $id = 0, $commit = true, &$error = '', User $user = null
*
* @since 1.19
*
- * @param string $reason delete reason for deletion log
- * @param $suppress boolean suppress all revisions and log the deletion in
- * the suppression log instead of the deletion log
- * @param int $id article ID
- * @param $commit boolean defaults to true, triggers transaction end
- * @param &$error Array of errors to append to
- * @param $user User The deleting user
- * @return 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
+ * @param string $reason Delete reason for deletion log
+ * @param bool $suppress Suppress all revisions and log the deletion in
+ * the suppression log instead of the deletion log
+ * @param int $id Article ID
+ * @param bool $commit Defaults to true, triggers transaction end
+ * @param array &$error Array of errors to append to
+ * @param User $user The deleting user
+ * @return 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
*/
public function doDeleteArticleReal(
$reason, $suppress = false, $id = 0, $commit = true, &$error = '', User $user = null
* Do some database updates after deletion
*
* @param int $id page_id value of the page being deleted
- * @param $content Content: optional 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.
+ * @param Content $content Optional 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.
*/
public function doDeleteUpdates( $id, Content $content = null ) {
// update site status
* @param string $fromP Name of the user whose edits to rollback.
* @param string $summary Custom summary. Set to default summary if empty.
* @param string $token Rollback token.
- * @param $bot Boolean: If true, mark all reverted edits as bot.
+ * @param bool $bot If true, mark all reverted edits as bot.
*
* @param array $resultDetails contains result-specific array of additional values
* 'alreadyrolled' : 'current' (rev)
* success : 'summary' (str), 'current' (rev), 'target' (rev)
*
- * @param $user User The user performing the rollback
- * @return array of errors, each error formatted as
+ * @param User $user The user performing the rollback
+ * @return 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().
* doRollback() instead.
* @param string $fromP Name of the user whose edits to rollback.
* @param string $summary Custom summary. Set to default summary if empty.
- * @param $bot Boolean: If true, mark all reverted edits as bot.
+ * @param bool $bot If true, mark all reverted edits as bot.
*
- * @param array $resultDetails contains result-specific array of additional values
- * @param $guser User The user performing the rollback
+ * @param array $resultDetails Contains result-specific array of additional values
+ * @param User $guser The user performing the rollback
* @return array
*/
public function commitRollback( $fromP, $summary, $bot, &$resultDetails, User $guser ) {
*
* This is called on page move and undelete, as well as edit
*
- * @param $title Title object
+ * @param Title $title
*/
public static function onArticleCreate( $title ) {
// Update existence markers on article/talk tabs...
/**
* Clears caches when article is deleted
*
- * @param $title Title
+ * @param Title $title
*/
public static function onArticleDelete( $title ) {
// Update existence markers on article/talk tabs...
/**
* Purge caches on page update etc
*
- * @param $title Title object
+ * @param Title $title
* @todo Verify that $title is always a Title object (and never false or null), add Title hint to parameter $title
*/
public static function onArticleEdit( $title ) {
* Returns a list of hidden categories this page is a member of.
* Uses the page_props and categorylinks tables.
*
- * @return Array of Title objects
+ * @return array Array of Title objects
*/
public function getHiddenCategories() {
$result = array();
/**
* Return an applicable autosummary if one exists for the given edit.
- * @param string|null $oldtext the previous text of the page.
+ * @param string|null $oldtext The previous text of the page.
* @param string|null $newtext The submitted text of the page.
- * @param int $flags bitmask: a bitmask of flags submitted for the edit.
+ * @param int $flags Bitmask: a bitmask of flags submitted for the edit.
* @return string An appropriate autosummary, or an empty string.
*
* @deprecated since 1.21, use ContentHandler::getAutosummary() instead
/**
* Auto-generates a deletion reason
*
- * @param &$hasHistory Boolean: whether the page has a history
- * @return mixed String containing deletion reason or empty string, or boolean false
+ * @param bool &$hasHistory Whether the page has a history
+ * @return string|bool String containing deletion reason or empty string, or boolean false
* if no revision occurred
*/
public function getAutoDeleteReason( &$hasHistory ) {
* Update all the appropriate counts in the category table, given that
* we've added the categories $added and deleted the categories $deleted.
*
- * @param array $added The names of categories that were added
+ * @param array $added The names of categories that were added
* @param array $deleted The names of categories that were deleted
*/
public function updateCategoryCounts( array $added, array $deleted ) {
/**
* Updates cascading protections
*
- * @param $parserOutput ParserOutput object for the current version
+ * @param ParserOutput $parserOutput ParserOutput object for the current version
*/
public function doCascadeProtectionUpdates( ParserOutput $parserOutput ) {
if ( wfReadOnly() || !$this->mTitle->areRestrictionsCascading() ) {
* Return a list of templates used by this article.
* Uses the templatelinks table
*
- * @deprecated in 1.19; use Title::getTemplateLinksFrom()
- * @return Array of Title objects
+ * @deprecated since 1.19; use Title::getTemplateLinksFrom()
+ * @return array Array of Title objects
*/
public function getUsedTemplates() {
return $this->mTitle->getTemplateLinksFrom();
* This function is called right before saving the wikitext,
* so we can do things like signatures and links-in-context.
*
- * @deprecated in 1.19; use Parser::preSaveTransform() instead
- * @param string $text article contents
- * @param $user User object: user doing the edit
- * @param $popts ParserOptions object: parser options, default options for
- * the user loaded if null given
- * @return string article contents with altered wikitext markup (signatures
+ * @deprecated since 1.19; use Parser::preSaveTransform() instead
+ * @param string $text Article contents
+ * @param User $user User doing the edit
+ * @param ParserOptions $popts Parser options, default options for
+ * the user loaded if null given
+ * @return string Article contents with altered wikitext markup (signatures
* converted, {{subst:}}, templates, etc.)
*/
public function preSaveTransform( $text, User $user = null, ParserOptions $popts = null ) {
/**
* Check whether the number of revisions of this page surpasses $wgDeleteRevisionsLimit
*
- * @deprecated in 1.19; use Title::isBigDeletion() instead.
+ * @deprecated since 1.19; use Title::isBigDeletion() instead.
* @return bool
*/
public function isBigDeletion() {
/**
* Get the approximate revision count of this page.
*
- * @deprecated in 1.19; use Title::estimateRevisionCount() instead.
+ * @deprecated since 1.19; use Title::estimateRevisionCount() instead.
* @return int
*/
public function estimateRevisionCount() {
* Update the article's restriction field, and leave a log entry.
*
* @deprecated since 1.19
- * @param array $limit set of restriction keys
- * @param $reason String
- * @param &$cascade Integer. Set to false if cascading protection isn't allowed.
- * @param array $expiry per restriction type expiration
- * @param $user User The user updating the restrictions
+ * @param array $limit Set of restriction keys
+ * @param string $reason
+ * @param int &$cascade Set to false if cascading protection isn't allowed.
+ * @param array $expiry Per restriction type expiration
+ * @param User $user The user updating the restrictions
* @return bool true on success
*/
public function updateRestrictions(
* 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.
*
- * @param Content|null $content optional Content object for determining the necessary updates
- * @return Array an array of DataUpdates objects
+ * @param Content|null $content Optional Content object for determining the necessary updates
+ * @return array An array of DataUpdates objects
*/
public function getDeletionUpdates( Content $content = null ) {
if ( !$content ) {
private $cacheKey;
/**
- * @var integer
+ * @var int
*/
private $revid;
/**
* Constructor
*
- * @param $page Page|WikiPage
- * @param $revid Integer: ID of the revision being parsed
- * @param $useParserCache Boolean: whether to use the parser cache
- * @param $parserOptions parserOptions to use for the parse operation
- * @param $content Content|String: content to parse or null to load it; may also be given as a wikitext string, for BC
+ * @param Page $page
+ * @param int $revid ID of the revision being parsed
+ * @param bool $useParserCache Whether to use the parser cache
+ * @param ParserOptions $parserOptions ParserOptions to use for the parse operation
+ * @param Content|string $content Content to parse or null to load it; may also be given as a wikitext string, for BC
*/
public function __construct( Page $page, ParserOptions $parserOptions, $revid, $useParserCache, $content = null ) {
if ( is_string( $content ) ) { // BC: old style call
$this->page->getTitle()->getPrefixedDBkey() ) );
}
- if ( $this->cacheable && $this->parserOutput->isCacheable() ) {
+ if ( $this->cacheable && $this->parserOutput->isCacheable() && $isCurrent ) {
ParserCache::singleton()->save(
- $this->parserOutput, $this->page, $this->parserOptions, $cacheTime );
+ $this->parserOutput, $this->page, $this->parserOptions, $cacheTime, $this->revid );
}
// Make sure file cache is not used on uncacheable content.
}
/**
- * @param $status Status
+ * @param Status $status
* @return bool
*/
public function error( $status ) {