Use short assignment operator in PHP
[lhc/web/wiklou.git] / includes / EditPage.php
index 6ca8593..2048b87 100644 (file)
@@ -627,14 +627,23 @@ class EditPage {
                if ( $permErrors ) {
                        wfDebug( __METHOD__ . ": User can't edit\n" );
 
-                       // track block with a cookie if it doesn't exists already
-                       $this->context->getUser()->trackBlockWithCookie();
+                       if ( $this->context->getUser()->getBlock() ) {
+                               // track block with a cookie if it doesn't exists already
+                               $this->context->getUser()->trackBlockWithCookie();
+
+                               // Auto-block user's IP if the account was "hard" blocked
+                               if ( !wfReadOnly() ) {
+                                       DeferredUpdates::addCallableUpdate( function () {
+                                               $this->context->getUser()->spreadAnyEditBlock();
+                                       } );
+                               }
 
-                       // Auto-block user's IP if the account was "hard" blocked
-                       if ( !wfReadOnly() ) {
-                               DeferredUpdates::addCallableUpdate( function () {
-                                       $this->context->getUser()->spreadAnyEditBlock();
-                               } );
+                               $config = $this->context->getConfig();
+                               if ( $config->get( 'EnableBlockNoticeStats' ) ) {
+                                       $wiki = $config->get( 'DBname' );
+                                       $statsd = MediaWikiServices::getInstance()->getStatsdDataFactory();
+                                       $statsd->increment( 'BlockNotices.' . $wiki . '.WikitextEditor.shown' );
+                               }
                        }
                        $this->displayPermissionsError( $permErrors );
 
@@ -1661,7 +1670,7 @@ class EditPage {
                                        if ( $query === '' ) {
                                                $query = $extraQueryRedirect;
                                        } else {
-                                               $query = $query . '&' . $extraQueryRedirect;
+                                               $query .= '&' . $extraQueryRedirect;
                                        }
                                }
                                $anchor = $resultDetails['sectionanchor'] ?? '';
@@ -1689,7 +1698,7 @@ class EditPage {
                                        if ( $extraQuery === '' ) {
                                                $extraQuery = $extraQueryRedirect;
                                        } else {
-                                               $extraQuery = $extraQuery . '&' . $extraQueryRedirect;
+                                               $extraQuery .= '&' . $extraQueryRedirect;
                                        }
                                }
 
@@ -1960,7 +1969,7 @@ ERROR;
                        return $status;
                }
 
-               if ( $user->isBlockedFrom( $this->mTitle, false ) ) {
+               if ( $user->isBlockedFrom( $this->mTitle ) ) {
                        // Auto-block user's IP if the account was "hard" blocked
                        if ( !wfReadOnly() ) {
                                $user->spreadAnyEditBlock();
@@ -2602,8 +2611,13 @@ ERROR;
                        if ( !( $user && $user->isLoggedIn() ) && !$ip ) { # User does not exist
                                $out->wrapWikiMsg( "<div class=\"mw-userpage-userdoesnotexist error\">\n$1\n</div>",
                                        [ 'userpage-userdoesnotexist', wfEscapeWikiText( $username ) ] );
-                       } elseif ( !is_null( $block ) && $block->getType() != Block::TYPE_AUTO ) {
-                               # Show log extract if the user is currently blocked
+                       } elseif (
+                               !is_null( $block ) &&
+                               $block->getType() != Block::TYPE_AUTO &&
+                               ( $block->isSitewide() || $user->isBlockedFrom( $this->mTitle ) )
+                       ) {
+                               // Show log extract if the user is sitewide blocked or is partially
+                               // blocked and not allowed to edit their user page or user talk page
                                LogEventsList::showLogExtract(
                                        $out,
                                        'block',
@@ -3236,15 +3250,13 @@ ERROR;
         * @return array
         */
        private function getSummaryInputAttributes( array $inputAttrs = null ) {
-               $conf = $this->context->getConfig();
-               $oldCommentSchema = $conf->get( 'CommentTableSchemaMigrationStage' ) === MIGRATION_OLD;
                // HTML maxlength uses "UTF-16 code units", which means that characters outside BMP
                // (e.g. emojis) count for two each. This limit is overridden in JS to instead count
-               // Unicode codepoints (or 255 UTF-8 bytes for old schema).
+               // Unicode codepoints.
                return ( is_array( $inputAttrs ) ? $inputAttrs : [] ) + [
                        'id' => 'wpSummary',
                        'name' => 'wpSummary',
-                       'maxlength' => $oldCommentSchema ? 200 : CommentStore::COMMENT_CHARACTER_LIMIT,
+                       'maxlength' => CommentStore::COMMENT_CHARACTER_LIMIT,
                        'tabindex' => 1,
                        'size' => 60,
                        'spellcheck' => 'true',