r111662 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r111661‎ | r111662 | r111663 >
Date:18:59, 16 February 2012
Author:reedy
Status:ok
Tags:
Comment:
Modified paths:
  • /branches/wmf/1.19wmf1/extensions (modified) (history)
  • /branches/wmf/1.19wmf1/extensions/AntiSpoof/maintenance/batchAntiSpoof.php (modified) (history)
  • /branches/wmf/1.19wmf1/extensions/CentralAuth/AntiSpoof/batchCAAntiSpoof.php (modified) (history)

Diff [purge]

Index: branches/wmf/1.19wmf1/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 );
Index: branches/wmf/1.19wmf1/extensions/CentralAuth/AntiSpoof/batchCAAntiSpoof.php
@@ -20,8 +20,30 @@
2121 * @return DatabaseBase
2222 */
2323 protected function getDB() {
24 - CentralAuthUser::getCentralDB();
 24+ return CentralAuthUser::getCentralDB();
2525 }
 26+
 27+ /**
 28+ * @return string
 29+ */
 30+ protected function getTableName() {
 31+ return 'globaluser';
 32+ }
 33+
 34+ /**
 35+ * @return string
 36+ */
 37+ protected function getUserColumn() {
 38+ return 'gu_name';
 39+ }
 40+
 41+ /**
 42+ * @param $name string
 43+ * @return CentralAuthSpoofUser
 44+ */
 45+ protected function makeSpoofUser( $name ) {
 46+ return new CentralAuthSpoofUser( $name );
 47+ }
2648 }
2749
2850 $maintClass = "BatchCAAntiSpoof";
Property changes on: branches/wmf/1.19wmf1/extensions
___________________________________________________________________
Modified: svn:mergeinfo
2951 Merged /trunk/extensions:r111659-111661

Sign-offs

UserFlagDate
Nikerabbitinspected06:32, 17 February 2012

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r111659Actually returning the object is a good starting pointreedy18:52, 16 February 2012
r111660Extract table name and user columns out of main script...reedy18:55, 16 February 2012
r111661Update batchCAAntiSpoof.php per r111660reedy18:56, 16 February 2012

Status & tagging log