}
/**
- * @deprecated use Article::doEdit()
+ * This function is not deprecated until somebody fixes the core not to use
+ * it. Nevertheless, use Article::doEdit() instead.
*/
function insertNewArticle( $text, $summary, $isminor, $watchthis, $suppressRC = false, $comment = false, $bot = false ) {
- wfDeprecated( __METHOD__ );
$flags = EDIT_NEW | EDIT_DEFER_UPDATES | EDIT_AUTOSUMMARY |
( $isminor ? EDIT_MINOR : 0 ) |
( $suppressRC ? EDIT_SUPPRESS_RC : 0 ) |
( $bot ? EDIT_FORCE_BOT : 0 );
- $this->doEdit( $text, $summary, $flags, false, null, $watchthis, $comment, '', true );
+ # If this is a comment, add the summary as headline
+ if ( $comment && $summary != "" ) {
+ $text = wfMsgForContent( 'newsectionheaderdefaultlevel', $summary ) . "\n\n" . $text;
+ }
+ $this->doEdit( $text, $summary, $flags );
+
+ $dbw = wfGetDB( DB_MASTER );
+ if ( $watchthis ) {
+ if ( !$this->mTitle->userIsWatching() ) {
+ $dbw->begin();
+ $this->doWatch();
+ $dbw->commit();
+ }
+ } else {
+ if ( $this->mTitle->userIsWatching() ) {
+ $dbw->begin();
+ $this->doUnwatch();
+ $dbw->commit();
+ }
+ }
+ $this->doRedirect( $this->isRedirect( $text ) );
}
/**
* @deprecated use Article::doEdit()
*/
function updateArticle( $text, $summary, $minor, $watchthis, $forceBot = false, $sectionanchor = '' ) {
- wfDeprecated( __METHOD__ );
$flags = EDIT_UPDATE | EDIT_DEFER_UPDATES | EDIT_AUTOSUMMARY |
( $minor ? EDIT_MINOR : 0 ) |
( $forceBot ? EDIT_FORCE_BOT : 0 );
- $status = $this->doEdit( $text, $summary, $flags, false, null, $watchthis, false, $sectionanchor, true );
+ $status = $this->doEdit( $text, $summary, $flags );
if ( !$status->isOK() ) {
return false;
}
+ $dbw = wfGetDB( DB_MASTER );
+ if ( $watchthis ) {
+ if ( !$this->mTitle->userIsWatching() ) {
+ $dbw->begin();
+ $this->doWatch();
+ $dbw->commit();
+ }
+ } else {
+ if ( $this->mTitle->userIsWatching() ) {
+ $dbw->begin();
+ $this->doUnwatch();
+ $dbw->commit();
+ }
+ }
+
+ $extraQuery = ''; // Give extensions a chance to modify URL query on update
+ wfRunHooks( 'ArticleUpdateBeforeRedirect', array( $this, &$sectionanchor, &$extraQuery ) );
+
+ $this->doRedirect( $this->isRedirect( $text ), $sectionanchor, $extraQuery );
return true;
}
*
* @param $baseRevId the revision ID this edit was based off, if any
* @param $user Optional user object, $wgUser will be used if not passed
- * @param $watchthis Watch the page if true, unwatch the page if false, do nothing if null
- * @param $comment Boolean: whether the edit is a new section
- * @param $sectionanchor The section anchor for the page; used for redirecting the user back to the page
- * after the edit is successfully committed
- * @param $redirect If true, redirect the user back to the page after the edit is successfully committed
*
* @return Status object. Possible errors:
* edit-hook-aborted: The ArticleSave hook aborted the edit but didn't set the fatal flag of $status
*
* Compatibility note: this function previously returned a boolean value indicating success/failure
*/
- public function doEdit( $text, $summary, $flags = 0, $baseRevId = false, $user = null , $watchthis = null,
- $comment = false, $sectionanchor = '', $redirect = false) {
+ public function doEdit( $text, $summary, $flags = 0, $baseRevId = false, $user = null ) {
global $wgUser, $wgDBtransactions, $wgUseAutomaticEditSummaries;
# Low-level sanity check
$flags = $this->checkFlags( $flags );
- # If this is a comment, add the summary as headline
- if ( $comment && $summary != "" ) {
- $text = wfMsgForContent( 'newsectionheaderdefaultlevel', $summary ) . "\n\n" . $text;
- }
-
if ( !wfRunHooks( 'ArticleSave', array( &$this, &$user, &$text, &$summary,
- $flags & EDIT_MINOR, &$watchthis, null, &$flags, &$status) ) )
+ $flags & EDIT_MINOR, null, null, &$flags, &$status ) ) )
{
wfDebug( __METHOD__ . ": ArticleSave hook aborted save!\n" );
wfProfileOut( __METHOD__ );
Article::onArticleCreate( $this->mTitle );
wfRunHooks( 'ArticleInsertComplete', array( &$this, &$user, $text, $summary,
- $flags & EDIT_MINOR, &$watchthis, null, &$flags, $revision ) );
+ $flags & EDIT_MINOR, null, null, &$flags, $revision ) );
}
# Do updates right now unless deferral was requested
$status->value['revision'] = $revision;
wfRunHooks( 'ArticleSaveComplete', array( &$this, &$user, $text, $summary,
- $flags & EDIT_MINOR, &$watchthis, null, &$flags, $revision, &$status, $baseRevId,
- &$redirect) );
-
- # Watch or unwatch the page
- if ( $watchthis === true ) {
- if ( !$this->mTitle->userIsWatching() ) {
- $dbw->begin();
- $this->doWatch();
- $dbw->commit();
- }
- } elseif ( $watchthis === false ) {
- if ( $this->mTitle->userIsWatching() ) {
- $dbw->begin();
- $this->doUnwatch();
- $dbw->commit();
- }
- }
-
- # Give extensions a chance to modify URL query on update
- $extraQuery = '';
-
- wfRunHooks( 'ArticleUpdateBeforeRedirect', array( $this, &$sectionanchor, &$extraQuery ) );
-
- if ( $redirect ) {
- if ( $sectionanchor || $extraQuery ) {
- $this->doRedirect( $this->isRedirect( $text ), $sectionanchor, $extraQuery );
- } else {
- $this->doRedirect( $this->isRedirect( $text ) );
- }
- }
+ $flags & EDIT_MINOR, null, null, &$flags, $revision, &$status, $baseRevId ) );
wfProfileOut( __METHOD__ );
-
return $status;
}
$isComment = ( $this->section == 'new' );
- $flags = EDIT_NEW | EDIT_DEFER_UPDATES | EDIT_AUTOSUMMARY |
- ( $this->minoredit ? EDIT_MINOR : 0 ) |
- ( $bot ? EDIT_FORCE_BOT : 0 );
- $status = $this->mArticle->doEdit( $this->textbox1, $this->summary, $flags,
- false, null, $this->watchthis, $isComment, '', true );
+ $this->mArticle->insertNewArticle( $this->textbox1, $this->summary,
+ $this->minoredit, $this->watchthis, false, $isComment, $bot );
- if ( $status->isOK() ) {
- wfProfileOut( __METHOD__ );
- return self::AS_SUCCESS_NEW_ARTICLE;
- } else {
- $result = $status->getErrorsArray();
- }
wfProfileOut( __METHOD__ );
- return self::AS_END;
+ return self::AS_SUCCESS_NEW_ARTICLE;
}
# Article exists. Check for edit conflict.
return self::AS_MAX_ARTICLE_SIZE_EXCEEDED;
}
- // Update the article here
- $flags = EDIT_UPDATE | EDIT_DEFER_UPDATES | EDIT_AUTOSUMMARY |
- ( $this->minoredit ? EDIT_MINOR : 0 ) |
- ( $bot ? EDIT_FORCE_BOT : 0 );
- $status = $this->mArticle->doEdit( $text, $this->summary, $flags,
- false, null, $this->watchthis, false, $sectionanchor, true );
-
- if ( $status->isOK() )
+ # update the article here
+ if ( $this->mArticle->updateArticle( $text, $this->summary, $this->minoredit,
+ $this->watchthis, $bot, $sectionanchor ) )
{
wfProfileOut( __METHOD__ );
return self::AS_SUCCESS_UPDATE;
} else {
$this->isConflict = true;
- $result = $status->getErrorsArray();
}
wfProfileOut( __METHOD__ );
return self::AS_END;