Page MenuHomePhabricator

patch_file_3

Authored By
bzimport
Nov 21 2014, 11:10 PM
Size
5 KB
Referenced Files
None
Subscribers
None

patch_file_3

Index: includes/Article.php
===================================================================
--- includes/Article.php (revision 66862)
+++ includes/Article.php (working copy)
@@ -1811,28 +1811,8 @@
( $suppressRC ? EDIT_SUPPRESS_RC : 0 ) |
( $bot ? EDIT_FORCE_BOT : 0 );
- # 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, false, null, $watchthis, $comment, '', true );
- $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 ) );
}
/**
@@ -1843,30 +1823,11 @@
( $minor ? EDIT_MINOR : 0 ) |
( $forceBot ? EDIT_FORCE_BOT : 0 );
- $status = $this->doEdit( $text, $summary, $flags );
+ $status = $this->doEdit( $text, $summary, $flags, false, null, $watchthis, false, $sectionanchor, true );
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;
}
@@ -1920,6 +1881,10 @@
*
* @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 $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
@@ -1936,7 +1901,8 @@
*
* Compatibility note: this function previously returned a boolean value indicating success/failure
*/
- public function doEdit( $text, $summary, $flags = 0, $baseRevId = false, $user = null ) {
+ public function doEdit( $text, $summary, $flags = 0, $baseRevId = false, $user = null , $watchthis = null,
+ $comment = false, $sectionanchor = '', $redirect = false) {
global $wgUser, $wgDBtransactions, $wgUseAutomaticEditSummaries;
# Low-level sanity check
@@ -1953,9 +1919,14 @@
$this->loadPageData();
$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, null, null, &$flags, &$status ) ) )
+ $flags & EDIT_MINOR, &$watchthis, null, &$flags, &$status) ) )
{
wfDebug( __METHOD__ . ": ArticleSave hook aborted save!\n" );
wfProfileOut( __METHOD__ );
@@ -2085,6 +2056,9 @@
Article::onArticleEdit( $this->mTitle );
# Update links tables, site stats, etc.
$this->editUpdates( $text, $summary, $isminor, $now, $revisionId, $changed );
+
+ $extraQuery = ''; // Give extensions a chance to modify URL query on update
+ wfRunHooks( 'ArticleUpdateBeforeRedirect', array( $this, &$sectionanchor, &$extraQuery ) );
} else {
# Create new article
$status->value['new'] = true;
@@ -2148,7 +2122,7 @@
Article::onArticleCreate( $this->mTitle );
wfRunHooks( 'ArticleInsertComplete', array( &$this, &$user, $text, $summary,
- $flags & EDIT_MINOR, null, null, &$flags, $revision ) );
+ $flags & EDIT_MINOR, &$watchthis, null, &$flags, $revision ) );
}
# Do updates right now unless deferral was requested
@@ -2160,9 +2134,34 @@
$status->value['revision'] = $revision;
wfRunHooks( 'ArticleSaveComplete', array( &$this, &$user, $text, $summary,
- $flags & EDIT_MINOR, null, null, &$flags, $revision, &$status, $baseRevId ) );
-
+ $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();
+ }
+ }
+
+ if ( $redirect ) {
+ if ( $sectionanchor || $extraQuery ) {
+ $this->doRedirect( $this->isRedirect( $text ), $sectionanchor, $extraQuery );
+ } else {
+ $this->doRedirect( $this->isRedirect( $text ) );
+ }
+ }
+
wfProfileOut( __METHOD__ );
+
return $status;
}

File Metadata

Mime Type
text/x-diff
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
6470
Default Alt Text
patch_file_3 (5 KB)

Event Timeline