From eb5e031f310ddd8ba871219dd7fa939a904ea638 Mon Sep 17 00:00:00 2001 From: Alexandre Emsenhuber Date: Sun, 18 Mar 2012 22:19:00 +0000 Subject: [PATCH] * (bug 35303) Make proxy and DNS blacklist blocking work again --- RELEASE-NOTES-1.19 | 1 + includes/User.php | 47 ++++++++++++++++++++++++---------------------- 2 files changed, 26 insertions(+), 22 deletions(-) diff --git a/RELEASE-NOTES-1.19 b/RELEASE-NOTES-1.19 index a5d58c81f7..6828098c43 100644 --- a/RELEASE-NOTES-1.19 +++ b/RELEASE-NOTES-1.19 @@ -24,6 +24,7 @@ production. preloaded into edit summary on section edit * (bug 31417) New ID mw-content-text around the actual page text, without categories, contentSub, ... The same div often also contains the class mw-content-ltr/rtl. +* (bug 35303) Proxy and DNS blacklist blocking works again === Configuration changes in 1.19 === * Removed SkinTemplateSetupPageCss hook; use BeforePageDisplay instead. diff --git a/includes/User.php b/includes/User.php index c7c64965a9..684a05c6f7 100644 --- a/includes/User.php +++ b/includes/User.php @@ -1273,10 +1273,6 @@ class User { // overwriting mBlockedby, surely? $this->load(); - $this->mBlockedby = 0; - $this->mHideName = 0; - $this->mAllowUsertalk = 0; - # We only need to worry about passing the IP address to the Block generator if the # user is not immune to autoblocks/hardblocks, and they are the current user so we # know which IP address they're actually coming from @@ -1287,30 +1283,37 @@ class User { } # User/IP blocking - $this->mBlock = Block::newFromTarget( $this->getName(), $ip, !$bFromSlave ); - if ( $this->mBlock instanceof Block ) { - wfDebug( __METHOD__ . ": Found block.\n" ); - $this->mBlockedby = $this->mBlock->getByName(); - $this->mBlockreason = $this->mBlock->mReason; - $this->mHideName = $this->mBlock->mHideName; - $this->mAllowUsertalk = !$this->mBlock->prevents( 'editownusertalk' ); - } + $block = Block::newFromTarget( $this->getName(), $ip, !$bFromSlave ); # Proxy blocking - if ( $ip !== null && !$this->isAllowed( 'proxyunbannable' ) && !in_array( $ip, $wgProxyWhitelist ) ) { + if ( !$block instanceof Block && $ip !== null && !$this->isAllowed( 'proxyunbannable' ) + && !in_array( $ip, $wgProxyWhitelist ) ) + { # Local list if ( self::isLocallyBlockedProxy( $ip ) ) { - $this->mBlockedby = wfMsg( 'proxyblocker' ); - $this->mBlockreason = wfMsg( 'proxyblockreason' ); + $block = new Block; + $block->setBlocker( wfMsg( 'proxyblocker' ) ); + $block->mReason = wfMsg( 'proxyblockreason' ); + $block->setTarget( $ip ); + } elseif ( $this->isAnon() && $this->isDnsBlacklisted( $ip ) ) { + $block = new Block; + $block->setBlocker( wfMsg( 'sorbs' ) ); + $block->mReason = wfMsg( 'sorbsreason' ); + $block->setTarget( $ip ); } + } - # DNSBL - if ( !$this->mBlockedby && !$this->getID() ) { - if ( $this->isDnsBlacklisted( $ip ) ) { - $this->mBlockedby = wfMsg( 'sorbs' ); - $this->mBlockreason = wfMsg( 'sorbsreason' ); - } - } + if ( $block instanceof Block ) { + wfDebug( __METHOD__ . ": Found block.\n" ); + $this->mBlock = $block; + $this->mBlockedby = $block->getByName(); + $this->mBlockreason = $block->mReason; + $this->mHideName = $block->mHideName; + $this->mAllowUsertalk = !$block->prevents( 'editownusertalk' ); + } else { + $this->mBlockedby = ''; + $this->mHideName = 0; + $this->mAllowUsertalk = false; } # Extensions -- 2.20.1