Merge "Fix undo edit summary when the user who made the old revision is hidden"
[lhc/web/wiklou.git] / includes / EditPage.php
index c97431a..84bb493 100644 (file)
@@ -935,7 +935,19 @@ class EditPage {
                                                        # If we just undid one rev, use an autosummary
                                                        $firstrev = $oldrev->getNext();
                                                        if ( $firstrev && $firstrev->getId() == $undo ) {
-                                                               $undoSummary = wfMessage( 'undo-summary', $undo, $undorev->getUserText() )->inContentLanguage()->text();
+                                                               $userText = $undorev->getUserText();
+                                                               if ( $userText === '' ) {
+                                                                       $undoSummary = wfMessage(
+                                                                               'undo-summary-username-hidden',
+                                                                               $undo
+                                                                       )->inContentLanguage()->text();
+                                                               } else {
+                                                                       $undoSummary = wfMessage(
+                                                                               'undo-summary',
+                                                                               $undo,
+                                                                               $userText
+                                                                       )->inContentLanguage()->text();
+                                                               }
                                                                if ( $this->summary === '' ) {
                                                                        $this->summary = $undoSummary;
                                                                } else {
@@ -1743,7 +1755,9 @@ class EditPage {
        protected function updateWatchlist() {
                global $wgUser;
 
-               if ( $wgUser->isLoggedIn() && $this->watchthis != $wgUser->isWatched( $this->mTitle ) ) {
+               if ( $wgUser->isLoggedIn()
+                       && $this->watchthis != $wgUser->isWatched( $this->mTitle, WatchedItem::IGNORE_USER_RIGHTS )
+               ) {
                        $fname = __METHOD__;
                        $title = $this->mTitle;
                        $watch = $this->watchthis;
@@ -1752,11 +1766,7 @@ class EditPage {
                        $dbw = wfGetDB( DB_MASTER );
                        $dbw->onTransactionIdle( function() use ( $dbw, $title, $watch, $wgUser, $fname ) {
                                $dbw->begin( $fname );
-                               if ( $watch ) {
-                                       WatchAction::doWatch( $title, $wgUser );
-                               } else {
-                                       WatchAction::doUnwatch( $title, $wgUser );
-                               }
+                               WatchAction::doWatchOrUnwatch( $watch, $title, $wgUser );
                                $dbw->commit( $fname );
                        } );
                }
@@ -2138,7 +2148,7 @@ class EditPage {
                        }
                }
 
-               //@todo: add EditForm plugin interface and use it here!
+               // @todo add EditForm plugin interface and use it here!
                //       search for textarea1 and textares2, and allow EditForm to override all uses.
                $wgOut->addHTML( Html::openElement( 'form', array( 'id' => self::EDITFORM_ID, 'name' => self::EDITFORM_ID,
                        'method' => 'post', 'action' => $this->getActionURL( $this->getContextTitle() ),