r111660 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r111659‎ | r111660 | r111661 >
Date:18:55, 16 February 2012
Author:reedy
Status:ok
Tags:
Comment:
Extract table name and user columns out of main script

Comment out the bufferResults, seems to cause issues!
Modified paths:
  • /trunk/extensions/AntiSpoof/maintenance/batchAntiSpoof.php (modified) (history)

Diff [purge]

Index: trunk/extensions/AntiSpoof/maintenance/batchAntiSpoof.php
@@ -17,17 +17,40 @@
1818 }
1919
2020 /**
 21+ * @return string
 22+ */
 23+ protected function getTableName() {
 24+ return 'user';
 25+ }
 26+
 27+ /**
 28+ * @return string
 29+ */
 30+ protected function getUserColumn() {
 31+ return 'user_name';
 32+ }
 33+
 34+ /**
 35+ * @param $name string
 36+ * @return SpoofUser
 37+ */
 38+ protected function makeSpoofUser( $name ) {
 39+ return new SpoofUser( $name );
 40+ }
 41+
 42+ /**
2143 * Do the actual work. All child classes will need to implement this
2244 */
2345 public function execute() {
2446 $dbw = $this->getDB( DB_MASTER );
2547
26 - $dbw->bufferResults( false );
 48+ // $dbw->bufferResults( false );
2749
2850 $batchSize = 1000;
2951
3052 $this->output( "Creating username spoofs...\n" );
31 - $result = $dbw->select( 'user', 'user_name', null, __FUNCTION__ );
 53+ $userCol = $this->getUserColumn();
 54+ $result = $dbw->select( $this->getTableName(), $userCol, null, __FUNCTION__ );
3255 $n = 0;
3356 $items = array();
3457 foreach( $result as $row ) {
@@ -35,7 +58,7 @@
3659 $this->output( "...$n\n" );
3760 }
3861
39 - $items[] = new SpoofUser( $row->user_name );
 62+ $items[] = $this->makeSpoofUser( $row->$userCol );
4063
4164 if ( $n % $batchSize == 0 ) {
4265 $this->batchRecord( $items );

Sign-offs

UserFlagDate
Nikerabbitinspected06:31, 17 February 2012

Follow-up revisions

RevisionCommit summaryAuthorDate
r111661Update batchCAAntiSpoof.php per r111660reedy18:56, 16 February 2012
r111662MFT r111659, r111660, r111661reedy18:59, 16 February 2012

Status & tagging log