Use WIS:addWatchBatchForUser in SpecialEditWatchlist
[lhc/web/wiklou.git] / includes / EditPage.php
index 82fcdcf..b3bb07a 100644 (file)
@@ -530,11 +530,12 @@ class EditPage {
                if ( $permErrors ) {
                        wfDebug( __METHOD__ . ": User can't edit\n" );
                        // Auto-block user's IP if the account was "hard" blocked
-                       $user = $wgUser;
-                       DeferredUpdates::addCallableUpdate( function() use ( $user ) {
-                               $user->spreadAnyEditBlock();
-                       } );
-
+                       if ( !wfReadOnly() ) {
+                               $user = $wgUser;
+                               DeferredUpdates::addCallableUpdate( function () use ( $user ) {
+                                       $user->spreadAnyEditBlock();
+                               } );
+                       }
                        $this->displayPermissionsError( $permErrors );
 
                        return;
@@ -1520,7 +1521,7 @@ class EditPage {
                                // is if an extension hook aborted from inside ArticleSave.
                                // Render the status object into $this->hookError
                                // FIXME this sucks, we should just use the Status object throughout
-                               $this->hookError = '<div class="error">' . $status->getWikitext() .
+                               $this->hookError = '<div class="error">' . $status->getWikiText() .
                                        '</div>';
                                return true;
                }
@@ -1735,7 +1736,9 @@ class EditPage {
 
                if ( $wgUser->isBlockedFrom( $this->mTitle, false ) ) {
                        // Auto-block user's IP if the account was "hard" blocked
-                       $wgUser->spreadAnyEditBlock();
+                       if ( !wfReadOnly() ) {
+                               $wgUser->spreadAnyEditBlock();
+                       }
                        # Check block state against master, thus 'false'.
                        $status->setResult( false, self::AS_BLOCKED_PAGE_FOR_USER );
                        return $status;
@@ -2065,7 +2068,7 @@ class EditPage {
                if ( $changingContentModel ) {
                        $this->addContentModelChangeLogEntry(
                                $wgUser,
-                               $oldContentModel,
+                               $new ? false : $oldContentModel,
                                $this->contentModel,
                                $this->summary
                        );
@@ -2076,12 +2079,13 @@ class EditPage {
 
        /**
         * @param User $user
-        * @param string $oldModel
+        * @param string|false $oldModel false if the page is being newly created
         * @param string $newModel
         * @param string $reason
         */
        protected function addContentModelChangeLogEntry( User $user, $oldModel, $newModel, $reason ) {
-               $log = new ManualLogEntry( 'contentmodel', 'change' );
+               $new = $oldModel === false;
+               $log = new ManualLogEntry( 'contentmodel', $new ? 'new' : 'change' );
                $log->setPerformer( $user );
                $log->setTarget( $this->mTitle );
                $log->setComment( $reason );
@@ -2108,7 +2112,7 @@ class EditPage {
                $watch = $this->watchthis;
                // Do this in its own transaction to reduce contention...
                DeferredUpdates::addCallableUpdate( function () use ( $user, $title, $watch ) {
-                       if ( $watch == $user->isWatched( $title, WatchedItem::IGNORE_USER_RIGHTS ) ) {
+                       if ( $watch == $user->isWatched( $title, User::IGNORE_USER_RIGHTS ) ) {
                                return; // nothing to change
                        }
                        WatchAction::doWatchOrUnwatch( $watch, $title, $user );
@@ -2320,8 +2324,7 @@ class EditPage {
                # Show a warning message when someone creates/edits a user (talk) page but the user does not exist
                # Show log extract when the user is currently blocked
                if ( $namespace == NS_USER || $namespace == NS_USER_TALK ) {
-                       $parts = explode( '/', $this->mTitle->getText(), 2 );
-                       $username = $parts[0];
+                       $username = explode( '/', $this->mTitle->getText(), 2 )[0];
                        $user = User::newFromName( $username, false /* allow IP users*/ );
                        $ip = User::isIP( $username );
                        $block = Block::newFromTarget( $user, $user );
@@ -2540,7 +2543,7 @@ class EditPage {
                        Xml::openElement( 'div', [ 'id' => 'antispam-container', 'style' => 'display: none;' ] )
                        . Html::rawElement(
                                'label',
-                               [ 'for' => 'wpAntiSpam' ],
+                               [ 'for' => 'wpAntispam' ],
                                wfMessage( 'simpleantispam-label' )->parse()
                        )
                        . Xml::element(
@@ -2827,7 +2830,7 @@ class EditPage {
                } elseif ( $wgUser->isAnon() ) {
                        if ( $this->formtype != 'preview' ) {
                                $wgOut->wrapWikiMsg(
-                                       "<div id='mw-anon-edit-warning'>\n$1\n</div>",
+                                       "<div id='mw-anon-edit-warning' class='warningbox'>\n$1\n</div>",
                                        [ 'anoneditwarning',
                                                // Log-in link
                                                '{{fullurl:Special:UserLogin|returnto={{FULLPAGENAMEE}}}}',