Index: trunk/extensions/FlaggedRevs/maintenance/clearCachedText.php |
— | — | @@ -9,6 +9,7 @@ |
10 | 10 | if ( strval( $IP ) == '' ) { |
11 | 11 | $IP = dirname( __FILE__ ) . '/../../..'; |
12 | 12 | } |
| 13 | +$optionsWithArgs = array( 'backup' ); |
13 | 14 | require( "$IP/maintenance/commandLine.inc" ); |
14 | 15 | |
15 | 16 | $pageId = 0; |
— | — | @@ -19,6 +20,17 @@ |
20 | 21 | $batchSize = 1000; |
21 | 22 | $maxPage = $dbr->selectField( 'flaggedrevs', 'MAX(fr_page_id)', '', __METHOD__ ); |
22 | 23 | |
| 24 | +if ( !isset( $options['backup'] ) ) { |
| 25 | + echo "Usage: clearCachedText.php --backup=<file>\n"; |
| 26 | + exit( 1 ); |
| 27 | +} |
| 28 | + |
| 29 | +$backupFile = fopen( $options['backup'], 'w' ); |
| 30 | +if ( !$backupFile ) { |
| 31 | + echo "Unable to open backup file\n"; |
| 32 | + exit( 1 ); |
| 33 | +} |
| 34 | + |
23 | 35 | while ( true ) { |
24 | 36 | $res = $dbr->select( 'flaggedrevs', '*', |
25 | 37 | array( |
— | — | @@ -31,6 +43,9 @@ |
32 | 44 | } |
33 | 45 | foreach ( $res as $row ) { |
34 | 46 | $flags = explode( ',', $row->fr_flags ); |
| 47 | + $backupRecord = array( $row->fr_page_id, $row->fr_rev_id, $row->fr_flags, $row->fr_text ); |
| 48 | + fwrite( $backupFile, implode( "\t", array_map( 'rawurlencode', $backupRecord ) ) . "\n" ); |
| 49 | + |
35 | 50 | $dbw->update( 'flaggedrevs', |
36 | 51 | array( /* SET */ |
37 | 52 | 'fr_text' => '', |