* some source.
*
* @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
- * - "forupdate" or WikiPage::READ_LOCKING to get from the master DB using SELECT FOR UPDATE
+ * - 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.
+ * - "forupdate" or WikiPage::READ_LOCKING to get from the master DB
+ * using SELECT FOR UPDATE.
*
* @return void
*/
* @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!
+ public function getText( $audience = Revision::FOR_PUBLIC, User $user = null ) {
ContentHandler::deprecated( __METHOD__, '1.21' );
$this->loadLastEdit();
* @param bool $lastRevIsRedirect If given, will optimize adding and
* removing rows in redirect table.
* @return bool true on success, false on failure
- * @private
*/
- public function updateRevisionOn( $dbw, $revision, $lastRevision = null, $lastRevIsRedirect = null ) {
+ public function updateRevisionOn( $dbw, $revision, $lastRevision = null,
+ $lastRevIsRedirect = null
+ ) {
global $wgContentHandlerUseDB;
wfProfileIn( __METHOD__ );
*
* @deprecated since 1.21, use replaceSectionContent() instead
*/
- public function replaceSection( $section, $text, $sectionTitle = '', $edittime = null ) {
+ public function replaceSection( $section, $text, $sectionTitle = '',
+ $edittime = null
+ ) {
ContentHandler::deprecated( __METHOD__, '1.21' );
- if ( strval( $section ) == '' ) { //NOTE: keep condition in sync with condition in replaceSectionContent!
+ //NOTE: keep condition in sync with condition in replaceSectionContent!
+ if ( strval( $section ) == '' ) {
// Whole-page edit; let the whole text through
return $text;
}
*
* @return bool
*
- * @todo The skin should check this and not offer section functionality if sections are not supported.
- * @todo The EditPage should check this and not offer section functionality if sections are not supported.
+ * @todo The skin should check this and not offer section functionality if
+ * sections are not supported.
+ * @todo The EditPage should check this and not offer section functionality
+ * if sections are not supported.
*/
public function supportsSections() {
return $this->getContentHandler()->supportsSections();
* 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
+ * 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.
*
* @param bool|int $baseRevId The revision ID this edit was based off, if any
*
* @throws MWException
* @return Status object. 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
+ * 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.
+ * 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
+ * $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
+ * Compatibility note: this function previously returned a boolean value
+ * indicating success/failure
*
* @deprecated since 1.21: use doEditContent() instead.
*/
* 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
+ * 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.
*
* @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
+ * @param string $serialisation_format Format for storing the content in the
+ * database.
*
* @throws MWException
* @return Status object. 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
+ * 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
+ * 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
*/
// 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.
+ // We check for conflicts by comparing $oldid with the current latest revision ID.
$ok = $this->updateRevisionOn( $dbw, $revision, $oldid, $oldIsRedirect );
if ( !$ok ) {
$options = $this->getContentHandler()->makeParserOptions( $context );
if ( $this->getTitle()->isConversionTable() ) {
- // @todo ConversionTable should become a separate content model, so we don't need special cases like this one.
+ // @todo ConversionTable should become a separate content model, so
+ // we don't need special cases like this one.
$options->disableContentConversion();
}
$edit->format = $serialization_format;
$edit->popts = $this->makeParserOptions( 'canonical' );
- $edit->output = $edit->pstContent ? $edit->pstContent->getParserOutput( $this->mTitle, $revid, $edit->popts ) : null;
+ $edit->output = $edit->pstContent
+ ? $edit->pstContent->getParserOutput( $this->mTitle, $revid, $edit->popts )
+ : null;
$edit->newContent = $content;
$edit->oldContent = $this->getContent( Revision::RAW );
* @param User $user The user updating the restrictions
* @return Status
*/
- public function doUpdateRestrictions( array $limit, array $expiry, &$cascade, $reason, User $user ) {
+ public function doUpdateRestrictions( array $limit, array $expiry,
+ &$cascade, $reason, User $user
+ ) {
global $wgCascadingRestrictionLevels, $wgContLang;
if ( wfReadOnly() ) {
}
// Only certain restrictions can cascade...
- $editrestriction = isset( $limit['edit'] ) ? array( $limit['edit'] ) : $this->mTitle->getRestrictions( 'edit' );
+ $editrestriction = isset( $limit['edit'] )
+ ? array( $limit['edit'] )
+ : $this->mTitle->getRestrictions( 'edit' );
foreach ( array_keys( $editrestriction, 'sysop' ) as $key ) {
$editrestriction[$key] = 'editprotected'; // backwards compatibility
}
// insert null revision to identify the page protection change as edit summary
$latest = $this->getLatest();
- $nullRevision = $this->insertProtectNullRevision( $revCommentMsg, $limit, $expiry, $cascade, $reason, $user );
+ $nullRevision = $this->insertProtectNullRevision(
+ $revCommentMsg,
+ $limit,
+ $expiry,
+ $cascade,
+ $reason,
+ $user
+ );
+
if ( $nullRevision === null ) {
return Status::newFatal( 'no-null-revision', $this->mTitle->getPrefixedText() );
}
* @param User|null $user
* @return Revision|null Null on error
*/
- public function insertProtectNullRevision( $revCommentMsg, array $limit, array $expiry, $cascade, $reason, $user = null ) {
+ public function insertProtectNullRevision( $revCommentMsg, array $limit,
+ array $expiry, $cascade, $reason, $user = null
+ ) {
global $wgContLang;
$dbw = wfGetDB( DB_MASTER );
$protectDescription = $this->protectDescription( $limit, $expiry );
if ( $protectDescription ) {
$editComment .= wfMessage( 'word-separator' )->inContentLanguage()->text();
- $editComment .= wfMessage( 'parentheses' )->params( $protectDescription )->inContentLanguage()->text();
+ $editComment .= wfMessage( 'parentheses' )->params( $protectDescription )
+ ->inContentLanguage()->text();
}
if ( $cascade ) {
$editComment .= wfMessage( 'word-separator' )->inContentLanguage()->text();
$dbw->delete( 'revision', array( 'rev_page' => $id ), __METHOD__ );
}
+ // Clone the title, so we have the information we need when we log
+ $logTitle = clone $this->mTitle;
+
$this->doDeleteUpdates( $id, $content );
// Log the deletion, if the page was suppressed, log it at Oversight instead
$logEntry = new ManualLogEntry( $logtype, 'delete' );
$logEntry->setPerformer( $user );
- $logEntry->setTarget( $this->mTitle );
+ $logEntry->setTarget( $logTitle );
$logEntry->setComment( $reason );
$logid = $logEntry->insert();
$logEntry->publish( $logid );
* 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
if ( $s === false ) {
// No one else ever edited this page
return array( array( 'cantrollback' ) );
- } elseif ( $s->rev_deleted & Revision::DELETED_TEXT || $s->rev_deleted & Revision::DELETED_USER ) {
+ } elseif ( $s->rev_deleted & Revision::DELETED_TEXT
+ || $s->rev_deleted & Revision::DELETED_USER
+ ) {
// Only admins can see this text
return array( array( 'notvisiblerev' ) );
}
}
// Actually store the edit
- $status = $this->doEditContent( $target->getContent(), $summary, $flags, $target->getId(), $guser );
+ $status = $this->doEditContent(
+ $target->getContent(),
+ $summary,
+ $flags,
+ $target->getId(),
+ $guser
+ );
if ( !$status->isOK() ) {
return $status->getErrorsArray();
* Purge caches on page update etc
*
* @param Title $title
- * @todo Verify that $title is always a Title object (and never false or null), add Title hint to parameter $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 ) {
// Invalidate caches of articles which include this page
* @deprecated since 1.21, use ContentHandler::getAutosummary() instead
*/
public static function getAutosummary( $oldtext, $newtext, $flags ) {
- // NOTE: stub for backwards-compatibility. assumes the given text is wikitext. will break horribly if it isn't.
+ // NOTE: stub for backwards-compatibility. assumes the given text is
+ // wikitext. will break horribly if it isn't.
ContentHandler::deprecated( __METHOD__, '1.21' );
if ( count( $links_diff ) > 0 ) {
// Whee, link updates time.
- // Note: we are only interested in links here. We don't need to get other DataUpdate items from the parser output.
+ // Note: we are only interested in links here. We don't need to get
+ // other DataUpdate items from the parser output.
$u = new LinksUpdate( $this->mTitle, $parserOutput, false );
$u->doUpdate();
}
}
/**
- * 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.
+ * 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
+ * @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 ) {
}
class PoolWorkArticleView extends PoolCounterWork {
-
- /**
- * @var Page
- */
+ /** @var Page */
private $page;
- /**
- * @var string
- */
+ /** @var string */
private $cacheKey;
- /**
- * @var int
- */
+ /** @var int */
private $revid;
- /**
- * @var ParserOptions
- */
+ /** @var ParserOptions */
private $parserOptions;
- /**
- * @var Content|null
- */
+ /** @var Content|null */
private $content = null;
- /**
- * @var ParserOutput|bool
- */
+ /** @var ParserOutput|bool */
private $parserOutput = false;
- /**
- * @var bool
- */
+ /** @var bool */
private $isDirty = false;
- /**
- * @var Status|bool
- */
+ /** @var Status|bool */
private $error = false;
/**
- * Constructor
- *
* @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 ) {
+ * @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
$modelId = $page->getRevision()->getContentModel();
$format = $page->getRevision()->getContentFormat();
$cacheTime = wfTimestampNow();
$time = - microtime( true );
- $this->parserOutput = $content->getParserOutput( $this->page->getTitle(), $this->revid, $this->parserOptions );
+ $this->parserOutput = $content->getParserOutput(
+ $this->page->getTitle(),
+ $this->revid,
+ $this->parserOptions
+ );
$time += microtime( true );
// Timing hack