Index: trunk/phase3/maintenance/deleteArchivedRevisions.inc |
— | — | @@ -0,0 +1,35 @@ |
| 2 | +<?php
|
| 3 | +
|
| 4 | +/**
|
| 5 | + * Support functions for the deleteOldRevisions script
|
| 6 | + *
|
| 7 | + * @addtogroup Maintenance
|
| 8 | + * @author Rob Church <robchur@gmail.com>
|
| 9 | + */
|
| 10 | +
|
| 11 | +require_once( 'purgeOldText.inc' );
|
| 12 | +
|
| 13 | +function DeleteArchivedRevisions( $delete = false ) {
|
| 14 | +
|
| 15 | + # Data should come off the master, wrapped in a transaction
|
| 16 | + $dbw = wfGetDB( DB_MASTER );
|
| 17 | + $dbw->begin();
|
| 18 | +
|
| 19 | + $tbl_arch = $dbw->tableName( 'archive' );
|
| 20 | + # Delete as appropriate
|
| 21 | + echo( "Deleting archived revisions..." );
|
| 22 | + $dbw->query( "TRUNCATE TABLE $tbl_arch" );
|
| 23 | + echo( "done.\n" );
|
| 24 | +
|
| 25 | + $delete = $dbw->affectedRows() != 0;
|
| 26 | +
|
| 27 | + # This bit's done
|
| 28 | + # Purge redundant text records
|
| 29 | + $dbw->commit();
|
| 30 | + if( $delete ) {
|
| 31 | + PurgeRedundantText( true );
|
| 32 | + }
|
| 33 | +
|
| 34 | +}
|
| 35 | +
|
| 36 | +?> |
\ No newline at end of file |
Index: trunk/phase3/maintenance/deleteArchivedRevisions.php |
— | — | @@ -0,0 +1,30 @@ |
| 2 | +<?php
|
| 3 | +
|
| 4 | +/**
|
| 5 | + * Delete old (non-current) revisions from the database
|
| 6 | + *
|
| 7 | + * @addtogroup Maintenance
|
| 8 | + * @author Rob Church <robchur@gmail.com>
|
| 9 | + */
|
| 10 | +
|
| 11 | +$options = array( 'delete', 'help' );
|
| 12 | +require_once( 'commandLine.inc' );
|
| 13 | +require_once( 'deleteArchivedRevisions.inc' );
|
| 14 | +
|
| 15 | +echo( "Delete Archived Revisions\n\n" );
|
| 16 | +
|
| 17 | +if( @$options['help'] ) {
|
| 18 | + ShowUsage();
|
| 19 | +} else {
|
| 20 | + DeleteArchivedRevisions( @$options['delete'] );
|
| 21 | +}
|
| 22 | +
|
| 23 | +function ShowUsage() {
|
| 24 | + echo( "Deletes all archived revisions.\n\n" );
|
| 25 | + echo( "These revisions will no longer be restorable.\n\n" );
|
| 26 | + echo( "Usage: php deleteArchivedRevisions.php [--delete|--help]\n\n" );
|
| 27 | + echo( "delete : Performs the deletion\n" );
|
| 28 | + echo( " help : Show this usage information\n" );
|
| 29 | +}
|
| 30 | +
|
| 31 | +?> |
\ No newline at end of file |