Index: trunk/extensions/FlaggedRevs/maintenance/clearCachedText.php |
— | — | @@ -0,0 +1,51 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * Simple script to clear the fr_text field in a replication-friendly way |
| 6 | + */ |
| 7 | + |
| 8 | + |
| 9 | +$IP = getenv( 'MW_INSTALL_PATH' ); |
| 10 | +if ( strval( $IP ) == '' ) { |
| 11 | + $IP = dirname( __FILE__ ) . '/../../..'; |
| 12 | +} |
| 13 | +require( "$IP/maintenance/commandLine.inc" ); |
| 14 | + |
| 15 | +$pageId = 0; |
| 16 | +$revId = 0; |
| 17 | + |
| 18 | +$dbr = wfGetDB( DB_SLAVE ); |
| 19 | +$dbw = wfGetDB( DB_MASTER ); |
| 20 | +$batchSize = 1000; |
| 21 | +$maxPage = $dbr->selectField( 'flaggedrevs', 'MAX(fr_page_id)', '', __METHOD__ ); |
| 22 | + |
| 23 | +while ( true ) { |
| 24 | + $res = $dbr->select( 'flaggedrevs', '*', |
| 25 | + array( |
| 26 | + "fr_page_id > $pageId OR (fr_page_id = $pageId AND fr_rev_id > $revId)", |
| 27 | + "fr_flags NOT LIKE '%dynamic%'", |
| 28 | + ), __METHOD__, array( 'LIMIT' => $batchSize ) |
| 29 | + ); |
| 30 | + if ( !$res->numRows() ) { |
| 31 | + break; |
| 32 | + } |
| 33 | + foreach ( $res as $row ) { |
| 34 | + $flags = explode( ',', $row->fr_flags ); |
| 35 | + $dbw->update( 'flaggedrevs', |
| 36 | + array( /* SET */ |
| 37 | + 'fr_text' => '', |
| 38 | + 'fr_flags' => 'utf-8,dynamic', |
| 39 | + ), |
| 40 | + array( /* WHERE */ |
| 41 | + 'fr_page_id' => $row->fr_page_id, |
| 42 | + 'fr_rev_id' => $row->fr_rev_id, |
| 43 | + ), |
| 44 | + __METHOD__ |
| 45 | + ); |
| 46 | + } |
| 47 | + $pageId = $row->fr_page_id; |
| 48 | + $revId = $row->fr_rev_id; |
| 49 | + wfWaitForSlaves( 5 ); |
| 50 | + echo "$pageId / $maxPage\n"; |
| 51 | +} |
| 52 | + |
Property changes on: trunk/extensions/FlaggedRevs/maintenance/clearCachedText.php |
___________________________________________________________________ |
Name: svn:eol-style |
1 | 53 | + native |