Show block notice on contribs for range-blocked IP
authorPiRSquared17 <gerritpatchuploader@gmail.com>
Sat, 7 Jun 2014 22:43:15 +0000 (22:43 +0000)
committerKunal Mehta <legoktm@gmail.com>
Thu, 26 Jun 2014 22:52:21 +0000 (15:52 -0700)
Also on deleted contribs, user, user talk pages.

Bug: 20790
Change-Id: I3ed9cb56f91b52fdb0ba452422f9d0723e9abe41

RELEASE-NOTES-1.24
includes/EditPage.php
includes/page/Article.php
includes/specials/SpecialContributions.php
includes/specials/SpecialDeletedContributions.php

index c43e730..41b8473 100644 (file)
@@ -94,6 +94,8 @@ production.
 * Upgrade jStorage to v0.4.10.
 * {{!}} is now a magic word that produces the | character. This removes the need
   for Template:! for purposes such as passing pipes inside of parameters.
+* (bug 20790) The block log snippet on Special:Contributions and while
+  editing user and user talk pages now works for IP range blocks.
 
 === Bug fixes in 1.24 ===
 * (bug 49116) Footer copyright notice is now always displayed in user language
index 4642320..03e50fc 100644 (file)
@@ -2236,14 +2236,15 @@ class EditPage {
                        $username = $parts[0];
                        $user = User::newFromName( $username, false /* allow IP users*/ );
                        $ip = User::isIP( $username );
+                       $block = Block::newFromTarget( $user, $user );
                        if ( !( $user && $user->isLoggedIn() ) && !$ip ) { # User does not exist
                                $wgOut->wrapWikiMsg( "<div class=\"mw-userpage-userdoesnotexist error\">\n$1\n</div>",
                                        array( 'userpage-userdoesnotexist', wfEscapeWikiText( $username ) ) );
-                       } elseif ( $user->isBlocked() ) { # Show log extract if the user is currently blocked
+                       } elseif ( !is_null( $block ) && $block->getType() != Block::TYPE_AUTO ) { # Show log extract if the user is currently blocked
                                LogEventsList::showLogExtract(
                                        $wgOut,
                                        'block',
-                                       $user->getUserPage(),
+                                       MWNamespace::getCanonicalName( NS_USER ) . ':' . $block->getTarget(),
                                        '',
                                        array(
                                                'lim' => 1,
index 8a72815..0e989d3 100644 (file)
@@ -1163,15 +1163,16 @@ class Article implements Page {
                        $rootPart = $parts[0];
                        $user = User::newFromName( $rootPart, false /* allow IP users*/ );
                        $ip = User::isIP( $rootPart );
+                       $block = Block::newFromTarget( $user, $user );
 
                        if ( !( $user && $user->isLoggedIn() ) && !$ip ) { # User does not exist
                                $outputPage->wrapWikiMsg( "<div class=\"mw-userpage-userdoesnotexist error\">\n\$1\n</div>",
                                        array( 'userpage-userdoesnotexist-view', wfEscapeWikiText( $rootPart ) ) );
-                       } elseif ( $user->isBlocked() ) { # Show log extract if the user is currently blocked
+                       } elseif ( !is_null( $block ) && $block->getType() != Block::TYPE_AUTO ) { # Show log extract if the user is currently blocked
                                LogEventsList::showLogExtract(
                                        $outputPage,
                                        'block',
-                                       $user->getUserPage(),
+                                       MWNamespace::getCanonicalName( NS_USER ) . ':' . $block->getTarget(),
                                        '',
                                        array(
                                                'lim' => 1,
index 7481b0c..a1e8d2b 100644 (file)
@@ -270,7 +270,12 @@ class SpecialContributions extends IncludableSpecialPage {
                        // Show a note if the user is blocked and display the last block log entry.
                        // Do not expose the autoblocks, since that may lead to a leak of accounts' IPs,
                        // and also this will display a totally irrelevant log entry as a current block.
-                       if ( $userObj->isBlocked() && $userObj->getBlock()->getType() != Block::TYPE_AUTO ) {
+                       $block = Block::newFromTarget( $userObj, $userObj );
+                       if ( !is_null( $block ) && $block->getType() != Block::TYPE_AUTO ) {
+                               if ( $block->getType() == Block::TYPE_RANGE ) {
+                                       $nt = MWNamespace::getCanonicalName( NS_USER ) . ':' . $block->getTarget();
+                               }
+
                                $out = $this->getOutput(); // showLogExtract() wants first parameter by reference
                                LogEventsList::showLogExtract(
                                        $out,
index 5bec95b..4df5b2b 100644 (file)
@@ -472,7 +472,12 @@ class DeletedContributionsPage extends SpecialPage {
                        $links = $this->getLanguage()->pipeList( $tools );
 
                        // Show a note if the user is blocked and display the last block log entry.
-                       if ( $userObj->isBlocked() ) {
+                       $block = Block::newFromTarget( $userObj, $userObj );
+                       if ( !is_null( $block ) && $block->getType() != Block::TYPE_AUTO ) {
+                               if ( $block->getType() == Block::TYPE_RANGE ) {
+                                       $nt = MWNamespace::getCanonicalName( NS_USER ) . ':' . $block->getTarget();
+                               }
+
                                // LogEventsList::showLogExtract() wants the first parameter by ref
                                $out = $this->getOutput();
                                LogEventsList::showLogExtract(
@@ -485,7 +490,7 @@ class DeletedContributionsPage extends SpecialPage {
                                                'showIfEmpty' => false,
                                                'msgKey' => array(
                                                        'sp-contributions-blocked-notice',
-                                                       $nt->getText() # Support GENDER in 'sp-contributions-blocked-notice'
+                                                       $userObj->getName() # Support GENDER in 'sp-contributions-blocked-notice'
                                                ),
                                                'offset' => '' # don't use $this->getRequest() parameter offset
                                        )