X-Git-Url: https://scripts.mit.edu/gitweb/autoinstallsdev/mediawiki.git/blobdiff_plain/19e297c21b10b1b8a3acad5e73fc71dcb35db44a..6932310fd58ebef145fa01eb76edf7150284d8ea:/maintenance/purgeOldText.inc diff --git a/maintenance/purgeOldText.inc b/maintenance/purgeOldText.inc deleted file mode 100644 index 381d62a7..00000000 --- a/maintenance/purgeOldText.inc +++ /dev/null @@ -1,62 +0,0 @@ - - */ - -function PurgeRedundantText( $delete = false ) { - - # Data should come off the master, wrapped in a transaction - $dbw = wfGetDB( DB_MASTER ); - $dbw->begin(); - - $tbl_arc = $dbw->tableName( 'archive' ); - $tbl_rev = $dbw->tableName( 'revision' ); - $tbl_txt = $dbw->tableName( 'text' ); - - # Get "active" text records from the revisions table - echo( "Searching for active text records in revisions table..." ); - $res = $dbw->query( "SELECT DISTINCT rev_text_id FROM $tbl_rev" ); - foreach ( $res as $row ) { - $cur[] = $row->rev_text_id; - } - echo( "done.\n" ); - - # Get "active" text records from the archive table - echo( "Searching for active text records in archive table..." ); - $res = $dbw->query( "SELECT DISTINCT ar_text_id FROM $tbl_arc" ); - foreach ( $res as $row ) { - $cur[] = $row->ar_text_id; - } - echo( "done.\n" ); - - # Get the IDs of all text records not in these sets - echo( "Searching for inactive text records..." ); - $set = implode( ', ', $cur ); - $res = $dbw->query( "SELECT old_id FROM $tbl_txt WHERE old_id NOT IN ( $set )" ); - $old = array(); - foreach ( $res as $row ) { - $old[] = $row->old_id; - } - echo( "done.\n" ); - - # Inform the user of what we're going to do - $count = count( $old ); - echo( "$count inactive items found.\n" ); - - # Delete as appropriate - if ( $delete && $count ) { - echo( "Deleting..." ); - $set = implode( ', ', $old ); - $dbw->query( "DELETE FROM $tbl_txt WHERE old_id IN ( $set )" ); - echo( "done.\n" ); - } - - # Done - $dbw->commit(); - -}