Index: trunk/extensions/AntiSpoof/maintenance/batchAntiSpoof.php |
— | — | @@ -17,17 +17,40 @@ |
18 | 18 | } |
19 | 19 | |
20 | 20 | /** |
| 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 | + /** |
21 | 43 | * Do the actual work. All child classes will need to implement this |
22 | 44 | */ |
23 | 45 | public function execute() { |
24 | 46 | $dbw = $this->getDB( DB_MASTER ); |
25 | 47 | |
26 | | - $dbw->bufferResults( false ); |
| 48 | + // $dbw->bufferResults( false ); |
27 | 49 | |
28 | 50 | $batchSize = 1000; |
29 | 51 | |
30 | 52 | $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__ ); |
32 | 55 | $n = 0; |
33 | 56 | $items = array(); |
34 | 57 | foreach( $result as $row ) { |
— | — | @@ -35,7 +58,7 @@ |
36 | 59 | $this->output( "...$n\n" ); |
37 | 60 | } |
38 | 61 | |
39 | | - $items[] = new SpoofUser( $row->user_name ); |
| 62 | + $items[] = $this->makeSpoofUser( $row->$userCol ); |
40 | 63 | |
41 | 64 | if ( $n % $batchSize == 0 ) { |
42 | 65 | $this->batchRecord( $items ); |