* (bug 12999) introduce ipb_by_text colomn
authorVictor Vasiliev <vasilievvv@users.mediawiki.org>
Mon, 18 Feb 2008 12:16:23 +0000 (12:16 +0000)
committerVictor Vasiliev <vasilievvv@users.mediawiki.org>
Mon, 18 Feb 2008 12:16:23 +0000 (12:16 +0000)
N.B.: this is schema change (obviously)

includes/Block.php
includes/SpecialIpblocklist.php
maintenance/tables.sql
maintenance/updaters.inc

index 3688d7c..1733ebc 100644 (file)
@@ -16,8 +16,8 @@ class Block
 {
        /* public*/ var $mAddress, $mUser, $mBy, $mReason, $mTimestamp, $mAuto, $mId, $mExpiry,
                                $mRangeStart, $mRangeEnd, $mAnonOnly, $mEnableAutoblock, $mHideName, 
-                               $mBlockEmail;
-       /* private */ var $mNetworkBits, $mIntegerAddr, $mForUpdate, $mFromMaster, $mByName;
+                               $mBlockEmail, $mByName;
+       /* private */ var $mNetworkBits, $mIntegerAddr, $mForUpdate, $mFromMaster;
        
        const EB_KEEP_EXPIRED = 1;
        const EB_FOR_UPDATE = 2;
@@ -270,7 +270,7 @@ class Block
                if ( isset( $row->user_name ) ) {
                        $this->mByName = $row->user_name;
                } else {
-                       $this->mByName = false;
+                       $this->mByName = $row->ipb_by_text;
                }
                $this->mRangeStart = $row->ipb_range_start;
                $this->mRangeEnd = $row->ipb_range_end;
@@ -376,6 +376,15 @@ class Block
                        $this->mBlockEmail = 0; //Same goes for email...
                }
 
+               if( !$this->mByName ) {
+                       if( $this->mBy ) {
+                               $this->mByName = User::whoIs( $this->mBy );
+                       } else {
+                               global $wgUser;
+                               $this->mByName = $wgUser->getName();
+                       }
+               }
+
                # Don't collide with expired blocks
                Block::purgeExpired();
 
@@ -386,6 +395,7 @@ class Block
                                'ipb_address' => $this->mAddress,
                                'ipb_user' => $this->mUser,
                                'ipb_by' => $this->mBy,
+                               'ipb_by_text' => $this->mByName,
                                'ipb_reason' => $this->mReason,
                                'ipb_timestamp' => $dbw->timestamp($this->mTimestamp),
                                'ipb_auto' => $this->mAuto,
@@ -592,9 +602,6 @@ class Block
         */
        function getByName()
        {
-               if ( $this->mByName === false ) {
-                       $this->mByName = User::whoIs( $this->mBy );
-               }
                return $this->mByName;
        }
 
index c2de9e2..641e1fd 100644 (file)
@@ -393,7 +393,7 @@ class IPBlocklistPager extends ReverseChronologicalPager {
                # Usernames and titles are in fact related by a simple substitution of space -> underscore
                # The last few lines of Title::secureAndSplit() tell the story.
                while ( $row = $this->mResult->fetchObject() ) {
-                       $name = str_replace( ' ', '_', $row->user_name );
+                       $name = str_replace( ' ', '_', $row->ipb_by_text );
                        $lb->add( NS_USER, $name );
                        $lb->add( NS_USER_TALK, $name );
                        $name = str_replace( ' ', '_', $row->ipb_address );
@@ -414,10 +414,9 @@ class IPBlocklistPager extends ReverseChronologicalPager {
        function getQueryInfo() {
                $conds = $this->mConds;
                $conds[] = 'ipb_expiry>' . $this->mDb->addQuotes( $this->mDb->timestamp() );
-               $conds[] = 'ipb_by=user_id';
                return array(
-                       'tables' => array( 'ipblocks', 'user' ),
-                       'fields' => $this->mDb->tableName( 'ipblocks' ) . '.*,user_name',
+                       'tables' => 'ipblocks',
+                       'fields' => '*',
                        'conds' => $conds,
                );
        }
index 6282f52..b26498b 100644 (file)
@@ -597,6 +597,9 @@ CREATE TABLE /*$wgDBprefix*/ipblocks (
   -- User ID who made the block.
   ipb_by int unsigned NOT NULL default '0',
   
+  --User name of blocker
+  ipb_by_text varchar(255) binary NOT NULL default '',
+  
   -- Text comment made by blocker.
   ipb_reason tinyblob NOT NULL,
   
index 41a2b0a..e9a6ffc 100644 (file)
@@ -23,21 +23,21 @@ $wgRenamedTables = array(
 
 $wgNewTables = array(
 #            table          patch file (in maintenance/archives)
-       array( 'hitcounter',    'patch-hitcounter.sql' ),
-       array( 'querycache',    'patch-querycache.sql' ),
-       array( 'objectcache',   'patch-objectcache.sql' ),
-       array( 'categorylinks', 'patch-categorylinks.sql' ),
-       array( 'logging',       'patch-logging.sql' ),
-       array( 'user_newtalk',  'patch-usernewtalk2.sql' ),
-       array( 'transcache',    'patch-transcache.sql' ),
-       array( 'trackbacks',    'patch-trackbacks.sql' ),
-       array( 'externallinks', 'patch-externallinks.sql' ),
-       array( 'job',           'patch-job.sql' ),
-       array( 'langlinks',     'patch-langlinks.sql' ),
-       array( 'querycache_info', 'patch-querycacheinfo.sql' ),
-       array( 'filearchive',   'patch-filearchive.sql' ),
-       array( 'querycachetwo', 'patch-querycachetwo.sql' ),
-       array( 'redirect', 'patch-redirect.sql' ),
+       array( 'hitcounter',       'patch-hitcounter.sql' ),
+       array( 'querycache',       'patch-querycache.sql' ),
+       array( 'objectcache',      'patch-objectcache.sql' ),
+       array( 'categorylinks',    'patch-categorylinks.sql' ),
+       array( 'logging',          'patch-logging.sql' ),
+       array( 'user_newtalk',     'patch-usernewtalk2.sql' ),
+       array( 'transcache',       'patch-transcache.sql' ),
+       array( 'trackbacks',       'patch-trackbacks.sql' ),
+       array( 'externallinks',    'patch-externallinks.sql' ),
+       array( 'job',              'patch-job.sql' ),
+       array( 'langlinks',        'patch-langlinks.sql' ),
+       array( 'querycache_info',  'patch-querycacheinfo.sql' ),
+       array( 'filearchive',      'patch-filearchive.sql' ),
+       array( 'querycachetwo',    'patch-querycachetwo.sql' ),
+       array( 'redirect',         'patch-redirect.sql' ),
        array( 'protected_titles', 'patch-protected_titles.sql' ),
 );
 
@@ -84,6 +84,7 @@ $wgNewFields = array(
        array( 'oldimage',      'oi_metadata',      'patch-oi_metadata.sql'),
        array( 'archive',       'ar_page_id',       'patch-archive-page_id.sql'),
        array( 'image',         'img_sha1',         'patch-img_sha1.sql' ),
+       array( 'ipblocks',      'ipb_by_text',      'patch-ipb_by_text.sql' ),
 );
 
 # For extensions only, should be populated via hooks