r45177 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r45176‎ | r45177 | r45178 >
Date:08:31, 30 December 2008
Author:tstarling
Status:ok
Tags:
Comment:
Added theoretical reversibility
Modified paths:
  • /trunk/extensions/FlaggedRevs/maintenance/clearCachedText.php (modified) (history)

Diff [purge]

Index: trunk/extensions/FlaggedRevs/maintenance/clearCachedText.php
@@ -9,6 +9,7 @@
1010 if ( strval( $IP ) == '' ) {
1111 $IP = dirname( __FILE__ ) . '/../../..';
1212 }
 13+$optionsWithArgs = array( 'backup' );
1314 require( "$IP/maintenance/commandLine.inc" );
1415
1516 $pageId = 0;
@@ -19,6 +20,17 @@
2021 $batchSize = 1000;
2122 $maxPage = $dbr->selectField( 'flaggedrevs', 'MAX(fr_page_id)', '', __METHOD__ );
2223
 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+
2335 while ( true ) {
2436 $res = $dbr->select( 'flaggedrevs', '*',
2537 array(
@@ -31,6 +43,9 @@
3244 }
3345 foreach ( $res as $row ) {
3446 $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+
3550 $dbw->update( 'flaggedrevs',
3651 array( /* SET */
3752 'fr_text' => '',

Status & tagging log