From: PiRSquared17 Date: Sat, 7 Jun 2014 22:43:15 +0000 (+0000) Subject: Show block notice on contribs for range-blocked IP X-Git-Tag: 1.31.0-rc.0~15208 X-Git-Url: http://git.cyclocoop.org/%24href?a=commitdiff_plain;h=2b438eb5c191c6f595505b62943a85b2f3610a99;p=lhc%2Fweb%2Fwiklou.git Show block notice on contribs for range-blocked IP Also on deleted contribs, user, user talk pages. Bug: 20790 Change-Id: I3ed9cb56f91b52fdb0ba452422f9d0723e9abe41 --- diff --git a/RELEASE-NOTES-1.24 b/RELEASE-NOTES-1.24 index c43e730f7d..41b8473680 100644 --- a/RELEASE-NOTES-1.24 +++ b/RELEASE-NOTES-1.24 @@ -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 diff --git a/includes/EditPage.php b/includes/EditPage.php index 46423203ee..03e50fc89d 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -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( "
\n$1\n
", 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, diff --git a/includes/page/Article.php b/includes/page/Article.php index 8a72815b3a..0e989d3d2f 100644 --- a/includes/page/Article.php +++ b/includes/page/Article.php @@ -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( "
\n\$1\n
", 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, diff --git a/includes/specials/SpecialContributions.php b/includes/specials/SpecialContributions.php index 7481b0c226..a1e8d2bf1c 100644 --- a/includes/specials/SpecialContributions.php +++ b/includes/specials/SpecialContributions.php @@ -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, diff --git a/includes/specials/SpecialDeletedContributions.php b/includes/specials/SpecialDeletedContributions.php index 5bec95bd48..4df5b2b55f 100644 --- a/includes/specials/SpecialDeletedContributions.php +++ b/includes/specials/SpecialDeletedContributions.php @@ -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 )