Change rules when displaying block log extract
authorDayllan Maza <dmaza@wikimedia.org>
Fri, 30 Nov 2018 05:14:38 +0000 (00:14 -0500)
committerCatrope <roan@wikimedia.org>
Wed, 5 Dec 2018 22:58:46 +0000 (22:58 +0000)
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.

Bug: T203171
Change-Id: I9bcc50cfc1fad23f6bbbe5374a9a866f77bebc11

includes/EditPage.php
includes/page/Article.php

index 9e278af..400ea47 100644 (file)
@@ -1969,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();
@@ -2611,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',
index 9f7f280..c7c2c7f 100644 (file)
@@ -1367,8 +1367,13 @@ class Article implements Page {
                        if ( !( $user && $user->isLoggedIn() ) && !$ip ) { # User does not exist
                                $outputPage->wrapWikiMsg( "<div class=\"mw-userpage-userdoesnotexist error\">\n\$1\n</div>",
                                        [ 'userpage-userdoesnotexist-view', wfEscapeWikiText( $rootPart ) ] );
-                       } 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( $title ) )
+                       ) {
+                               // 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(
                                        $outputPage,
                                        'block',