r22127 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r22126‎ | r22127 | r22128 >
Date:17:56, 12 May 2007
Author:hashar
Status:old
Tags:
Comment:
svn:eol-style native
Modified paths:
  • /trunk/phase3/maintenance/deleteArchivedFiles.inc (modified) (history)
  • /trunk/phase3/maintenance/deleteArchivedFiles.php (modified) (history)
  • /trunk/phase3/maintenance/deleteArchivedRevisions.inc (modified) (history)
  • /trunk/phase3/maintenance/deleteArchivedRevisions.php (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/deleteArchivedRevisions.inc
@@ -1,35 +1,35 @@
2 -<?php
3 -
4 -/**
5 - * Support functions for the deleteArchivedRevisions script
6 - *
7 - * @addtogroup Maintenance
8 - * @author Aaron Schulz
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 -
 2+<?php
 3+
 4+/**
 5+ * Support functions for the deleteArchivedRevisions script
 6+ *
 7+ * @addtogroup Maintenance
 8+ * @author Aaron Schulz
 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+
3636 ?>
\ No newline at end of file
Property changes on: trunk/phase3/maintenance/deleteArchivedRevisions.inc
___________________________________________________________________
Added: svn:eol-style
3737 + native
Index: trunk/phase3/maintenance/deleteArchivedRevisions.php
@@ -1,31 +1,31 @@
2 -<?php
3 -
4 -/**
5 - * Delete arcived (deleted from public) revisions from the database
6 - *
7 - * @addtogroup Maintenance
8 - * @author Aaron Schulz
9 - * Shamelessly stolen from deleteOldRevisions.php by Rob Church :)
10 - */
11 -
12 -$options = array( 'delete', 'help' );
13 -require_once( 'commandLine.inc' );
14 -require_once( 'deleteArchivedRevisions.inc' );
15 -
16 -echo( "Delete Archived Revisions\n\n" );
17 -
18 -if( @$options['help'] ) {
19 - ShowUsage();
20 -} else {
21 - DeleteArchivedRevisions( @$options['delete'] );
22 -}
23 -
24 -function ShowUsage() {
25 - echo( "Deletes all archived revisions.\n\n" );
26 - echo( "These revisions will no longer be restorable.\n\n" );
27 - echo( "Usage: php deleteArchivedRevisions.php [--delete|--help]\n\n" );
28 - echo( "delete : Performs the deletion\n" );
29 - echo( " help : Show this usage information\n" );
30 -}
31 -
 2+<?php
 3+
 4+/**
 5+ * Delete arcived (deleted from public) revisions from the database
 6+ *
 7+ * @addtogroup Maintenance
 8+ * @author Aaron Schulz
 9+ * Shamelessly stolen from deleteOldRevisions.php by Rob Church :)
 10+ */
 11+
 12+$options = array( 'delete', 'help' );
 13+require_once( 'commandLine.inc' );
 14+require_once( 'deleteArchivedRevisions.inc' );
 15+
 16+echo( "Delete Archived Revisions\n\n" );
 17+
 18+if( @$options['help'] ) {
 19+ ShowUsage();
 20+} else {
 21+ DeleteArchivedRevisions( @$options['delete'] );
 22+}
 23+
 24+function ShowUsage() {
 25+ echo( "Deletes all archived revisions.\n\n" );
 26+ echo( "These revisions will no longer be restorable.\n\n" );
 27+ echo( "Usage: php deleteArchivedRevisions.php [--delete|--help]\n\n" );
 28+ echo( "delete : Performs the deletion\n" );
 29+ echo( " help : Show this usage information\n" );
 30+}
 31+
3232 ?>
\ No newline at end of file
Property changes on: trunk/phase3/maintenance/deleteArchivedRevisions.php
___________________________________________________________________
Added: svn:eol-style
3333 + native
Index: trunk/phase3/maintenance/deleteArchivedFiles.inc
@@ -1,57 +1,57 @@
2 -<?php
3 -
4 -/**
5 - * Support functions for the deleteArchivedFiles script
6 - *
7 - * @addtogroup Maintenance
8 - * @author Aaron Schulz
9 - */
10 -
11 -require_once( "$IP/includes/FileStore.php" );
12 -
13 -function DeleteArchivedFiles( $delete = false ) {
14 -
15 - # Data should come off the master, wrapped in a transaction
16 - $dbw = wfGetDB( DB_MASTER );
17 - $dbw->begin();
18 -
19 - $transaction = new FSTransaction();
20 - if( !FileStore::lock() ) {
21 - wfDebug( __METHOD__.": failed to acquire file store lock, aborting\n" );
22 - return false;
23 - }
24 -
25 - $tbl_arch = $dbw->tableName( 'filearchive' );
26 -
27 - # Get "active" revisions from the filearchive table
28 - echo( "Searching for and deleting archived files...\n" );
29 - $res = $dbw->query( "SELECT fa_id,fa_storage_group,fa_storage_key FROM $tbl_arch" );
30 - while( $row = $dbw->fetchObject( $res ) ) {
31 - $key = $row->fa_storage_key;
32 - $group = $row->fa_storage_group;
33 - $id = $row->fa_id;
34 -
35 - $store = FileStore::get( $group );
36 - if ( $store ) {
37 - $path = $store->filePath( $key );
38 - if ( $path && file_exists($path) ) {
39 - $transaction->addCommit( FSTransaction::DELETE_FILE, $path );
40 - $dbw->query( "DELETE FROM $tbl_arch WHERE fa_id = $id" );
41 - } else {
42 - echo( "Notice - file '$key' not found in group '$group'\n" );
43 - }
44 - } else {
45 - echo( "Notice - invalid file storage group '$group'\n" );
46 - }
47 - }
48 - echo( "done.\n" );
49 -
50 - $transaction->commit();
51 -
52 - # This bit's done
53 - # Purge redundant text records
54 - $dbw->commit();
55 -
56 -}
57 -
 2+<?php
 3+
 4+/**
 5+ * Support functions for the deleteArchivedFiles script
 6+ *
 7+ * @addtogroup Maintenance
 8+ * @author Aaron Schulz
 9+ */
 10+
 11+require_once( "$IP/includes/FileStore.php" );
 12+
 13+function DeleteArchivedFiles( $delete = false ) {
 14+
 15+ # Data should come off the master, wrapped in a transaction
 16+ $dbw = wfGetDB( DB_MASTER );
 17+ $dbw->begin();
 18+
 19+ $transaction = new FSTransaction();
 20+ if( !FileStore::lock() ) {
 21+ wfDebug( __METHOD__.": failed to acquire file store lock, aborting\n" );
 22+ return false;
 23+ }
 24+
 25+ $tbl_arch = $dbw->tableName( 'filearchive' );
 26+
 27+ # Get "active" revisions from the filearchive table
 28+ echo( "Searching for and deleting archived files...\n" );
 29+ $res = $dbw->query( "SELECT fa_id,fa_storage_group,fa_storage_key FROM $tbl_arch" );
 30+ while( $row = $dbw->fetchObject( $res ) ) {
 31+ $key = $row->fa_storage_key;
 32+ $group = $row->fa_storage_group;
 33+ $id = $row->fa_id;
 34+
 35+ $store = FileStore::get( $group );
 36+ if ( $store ) {
 37+ $path = $store->filePath( $key );
 38+ if ( $path && file_exists($path) ) {
 39+ $transaction->addCommit( FSTransaction::DELETE_FILE, $path );
 40+ $dbw->query( "DELETE FROM $tbl_arch WHERE fa_id = $id" );
 41+ } else {
 42+ echo( "Notice - file '$key' not found in group '$group'\n" );
 43+ }
 44+ } else {
 45+ echo( "Notice - invalid file storage group '$group'\n" );
 46+ }
 47+ }
 48+ echo( "done.\n" );
 49+
 50+ $transaction->commit();
 51+
 52+ # This bit's done
 53+ # Purge redundant text records
 54+ $dbw->commit();
 55+
 56+}
 57+
5858 ?>
\ No newline at end of file
Property changes on: trunk/phase3/maintenance/deleteArchivedFiles.inc
___________________________________________________________________
Added: svn:eol-style
5959 + native
Index: trunk/phase3/maintenance/deleteArchivedFiles.php
@@ -1,31 +1,31 @@
2 -<?php
3 -
4 -/**
5 - * Delete archived (non-current) files from the database
6 - *
7 - * @addtogroup Maintenance
8 - * @author Aaron Schulz
9 - * Based on deleteOldRevisions.php by Rob Church
10 - */
11 -
12 -$options = array( 'delete', 'help' );
13 -require_once( 'commandLine.inc' );
14 -require_once( 'deleteArchivedFiles.inc' );
15 -
16 -echo( "Delete Archived Images\n\n" );
17 -
18 -if( @$options['help'] ) {
19 - ShowUsage();
20 -} else {
21 - DeleteArchivedFiles( @$options['delete'] );
22 -}
23 -
24 -function ShowUsage() {
25 - echo( "Deletes all archived images.\n\n" );
26 - echo( "These images will no longer be restorable.\n\n" );
27 - echo( "Usage: php deleteArchivedRevisions.php [--delete|--help]\n\n" );
28 - echo( "delete : Performs the deletion\n" );
29 - echo( " help : Show this usage information\n" );
30 -}
31 -
 2+<?php
 3+
 4+/**
 5+ * Delete archived (non-current) files from the database
 6+ *
 7+ * @addtogroup Maintenance
 8+ * @author Aaron Schulz
 9+ * Based on deleteOldRevisions.php by Rob Church
 10+ */
 11+
 12+$options = array( 'delete', 'help' );
 13+require_once( 'commandLine.inc' );
 14+require_once( 'deleteArchivedFiles.inc' );
 15+
 16+echo( "Delete Archived Images\n\n" );
 17+
 18+if( @$options['help'] ) {
 19+ ShowUsage();
 20+} else {
 21+ DeleteArchivedFiles( @$options['delete'] );
 22+}
 23+
 24+function ShowUsage() {
 25+ echo( "Deletes all archived images.\n\n" );
 26+ echo( "These images will no longer be restorable.\n\n" );
 27+ echo( "Usage: php deleteArchivedRevisions.php [--delete|--help]\n\n" );
 28+ echo( "delete : Performs the deletion\n" );
 29+ echo( " help : Show this usage information\n" );
 30+}
 31+
3232 ?>
\ No newline at end of file
Property changes on: trunk/phase3/maintenance/deleteArchivedFiles.php
___________________________________________________________________
Added: svn:eol-style
3333 + native