r20436 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r20435‎ | r20436 | r20437 >
Date:05:24, 14 March 2007
Author:aaron
Status:old
Tags:
Comment:
*Add mHideName parameter for hiding usernames
Modified paths:
  • /trunk/phase3/includes/Block.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Block.php
@@ -15,7 +15,7 @@
1616 class Block
1717 {
1818 /* public*/ var $mAddress, $mUser, $mBy, $mReason, $mTimestamp, $mAuto, $mId, $mExpiry,
19 - $mRangeStart, $mRangeEnd, $mAnonOnly, $mEnableAutoblock;
 19+ $mRangeStart, $mRangeEnd, $mAnonOnly, $mEnableAutoblock, $mHideName;
2020 /* private */ var $mNetworkBits, $mIntegerAddr, $mForUpdate, $mFromMaster, $mByName;
2121
2222 const EB_KEEP_EXPIRED = 1;
@@ -23,7 +23,7 @@
2424 const EB_RANGE_ONLY = 4;
2525
2626 function __construct( $address = '', $user = 0, $by = 0, $reason = '',
27 - $timestamp = '' , $auto = 0, $expiry = '', $anonOnly = 0, $createAccount = 0, $enableAutoblock = 0 )
 27+ $timestamp = '' , $auto = 0, $expiry = '', $anonOnly = 0, $createAccount = 0, $enableAutoblock = 0, $hideName = 0 )
2828 {
2929 $this->mId = 0;
3030 # Expand valid IPv6 addresses
@@ -38,6 +38,7 @@
3939 $this->mCreateAccount = $createAccount;
4040 $this->mExpiry = self::decodeExpiry( $expiry );
4141 $this->mEnableAutoblock = $enableAutoblock;
 42+ $this->mHideName = $hideName;
4243
4344 $this->mForUpdate = false;
4445 $this->mFromMaster = false;
@@ -74,7 +75,7 @@
7576 $this->mAddress = $this->mReason = $this->mTimestamp = '';
7677 $this->mId = $this->mAnonOnly = $this->mCreateAccount =
7778 $this->mEnableAutoblock = $this->mAuto = $this->mUser =
78 - $this->mBy = 0;
 79+ $this->mBy = $this->mHideName = 0;
7980 $this->mByName = false;
8081 }
8182
@@ -147,7 +148,7 @@
148149 }
149150
150151 # Try range block
151 - if ( $this->loadRange( $address, $killExpired, $user ) ) {
 152+ if ( $this->loadRange( $address, $killExpired, $user == 0 ) ) {
152153 if ( $user && $this->mAnonOnly ) {
153154 $this->clear();
154155 return false;
@@ -260,6 +261,7 @@
261262 $this->mAnonOnly = $row->ipb_anon_only;
262263 $this->mCreateAccount = $row->ipb_create_account;
263264 $this->mEnableAutoblock = $row->ipb_enable_autoblock;
 265+ $this->mHideName = $row->ipb_deleted;
264266 $this->mId = $row->ipb_id;
265267 $this->mExpiry = self::decodeExpiry( $row->ipb_expiry );
266268 if ( isset( $row->user_name ) ) {
@@ -390,6 +392,7 @@
391393 'ipb_expiry' => self::encodeExpiry( $this->mExpiry, $dbw ),
392394 'ipb_range_start' => $this->mRangeStart,
393395 'ipb_range_end' => $this->mRangeEnd,
 396+ 'ipb_deleted' => $this->mHideName
394397 ), 'Block::insert', array( 'IGNORE' )
395398 );
396399 $affected = $dbw->affectedRows();
@@ -500,6 +503,8 @@
501504 $ipblock->mTimestamp = wfTimestampNow();
502505 $ipblock->mAuto = 1;
503506 $ipblock->mCreateAccount = $this->mCreateAccount;
 507+ # Continue suppressing the name if needed
 508+ $ipblock->mHideName = $this->mHideName;
504509
505510 # If the user is already blocked with an expiry date, we don't
506511 # want to pile on top of that!
@@ -633,9 +638,12 @@
634639 global $wgAutoblockExpiry;
635640 return wfTimestamp( TS_MW, wfTimestamp( TS_UNIX, $timestamp ) + $wgAutoblockExpiry );
636641 }
637 -
638 - static function normaliseRange( $range )
639 - {
 642+
 643+ /**
 644+ * Gets rid of uneeded numbers in quad-dotted IP strings
 645+ * For example, 127.111.113.151/24 -> 127.111.113.0/24
 646+ */
 647+ static function normaliseRange( $range ) {
640648 $parts = explode( '/', $range );
641649 if ( count( $parts ) == 2 ) {
642650 $shift = 32 - $parts[1];

Follow-up revisions

RevisionCommit summaryAuthorDate
r21400Fixed complete breakage of anon-only autoblocks, broken since r20436.tstarling04:17, 20 April 2007