summaryrefslogtreecommitdiff
path: root/maintenance/deleteOrphanedRevisions.php
diff options
context:
space:
mode:
Diffstat (limited to 'maintenance/deleteOrphanedRevisions.php')
-rw-r--r--maintenance/deleteOrphanedRevisions.php27
1 files changed, 13 insertions, 14 deletions
diff --git a/maintenance/deleteOrphanedRevisions.php b/maintenance/deleteOrphanedRevisions.php
index 1146befb..e972d1fa 100644
--- a/maintenance/deleteOrphanedRevisions.php
+++ b/maintenance/deleteOrphanedRevisions.php
@@ -24,7 +24,7 @@
* @todo More efficient cleanup of text records
*/
-require_once( dirname(__FILE__) . '/Maintenance.php' );
+require_once( dirname( __FILE__ ) . '/Maintenance.php' );
class DeleteOrphanedRevisions extends Maintenance {
public function __construct() {
@@ -36,7 +36,7 @@ class DeleteOrphanedRevisions extends Maintenance {
public function execute() {
$this->output( "Delete Orphaned Revisions\n" );
- $report = $this->hasOption('report');
+ $report = $this->hasOption( 'report' );
$dbw = wfGetDB( DB_MASTER );
$dbw->begin();
@@ -46,45 +46,44 @@ class DeleteOrphanedRevisions extends Maintenance {
$this->output( "Checking for orphaned revisions..." );
$sql = "SELECT rev_id FROM {$revision} LEFT JOIN {$page} ON rev_page = page_id WHERE page_namespace IS NULL";
$res = $dbw->query( $sql, 'deleteOrphanedRevisions' );
-
+
# Stash 'em all up for deletion (if needed)
$revisions = array();
- foreach( $res as $row )
+ foreach ( $res as $row )
$revisions[] = $row->rev_id;
- $dbw->freeResult( $res );
$count = count( $revisions );
$this->output( "found {$count}.\n" );
-
+
# Nothing to do?
- if( $report || $count == 0 ) {
+ if ( $report || $count == 0 ) {
$dbw->commit();
- exit(0);
+ exit( 0 );
}
-
+
# Delete each revision
$this->output( "Deleting..." );
$this->deleteRevs( $revisions, $dbw );
$this->output( "done.\n" );
-
+
# Close the transaction and call the script to purge unused text records
$dbw->commit();
$this->purgeRedundantText( true );
}
-
+
/**
* Delete one or more revisions from the database
* Do this inside a transaction
*
* @param $id Array of revision id values
- * @param $db Database class (needs to be a master)
+ * @param $dbw Database class (needs to be a master)
*/
private function deleteRevs( $id, &$dbw ) {
- if( !is_array( $id ) )
+ if ( !is_array( $id ) )
$id = array( $id );
$dbw->delete( 'revision', array( 'rev_id' => $id ), __METHOD__ );
}
}
$maintClass = "DeleteOrphanedRevisions";
-require_once( DO_MAINTENANCE );
+require_once( RUN_MAINTENANCE_IF_MAIN );