From 1c9773bd015adbf8aedb3b1777f0e087906baf6f Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Wed, 24 Jun 2009 02:49:24 +0000 Subject: Revert r52336 "Merge maintenance-work branch:" Seems to have broken a bunch of stuff. Don't commit giant non-critical changes that break Setup.php and all maint scripts. Thanks! --- maintenance/nukePage.php | 98 +++++++----------------------------------------- 1 file changed, 14 insertions(+), 84 deletions(-) (limited to 'maintenance/nukePage.php') diff --git a/maintenance/nukePage.php b/maintenance/nukePage.php index ac2059f223d5..b3bfc7626de4 100644 --- a/maintenance/nukePage.php +++ b/maintenance/nukePage.php @@ -1,4 +1,5 @@ */ -require_once( "Maintenance.php" ); - -class NukePage extends Maintenance { - public function __construct() { - parent::__construct(); - $this->mDescription = "Remove a page record from the database"; - $this->addParam( 'delete', "Actually delete the page" ); - $this->addArgs( array( 'title' ) ); - } - - public function execute() { - - $name = $this->getArg(); - $delete = $this->getOption( 'delete', false ); - - $dbw = wfGetDB( DB_MASTER ); - $dbw->begin(); - - $tbl_pag = $dbw->tableName( 'page' ); - $tbl_rec = $dbw->tableName( 'recentchanges' ); - $tbl_rev = $dbw->tableName( 'revision' ); - - # Get page ID - $this->output( "Searching for \"$name\"..." ); - $title = Title::newFromText( $name ); - if( $title ) { - $id = $title->getArticleID(); - $real = $title->getPrefixedText(); - $isGoodArticle = $title->isContentPage(); - $this->output( "found \"$real\" with ID $id.\n" ); +require_once( 'commandLine.inc' ); +require_once( 'nukePage.inc' ); - # Get corresponding revisions - $this->output( "Searching for revisions..." ); - $res = $dbw->query( "SELECT rev_id FROM $tbl_rev WHERE rev_page = $id" ); - while( $row = $dbw->fetchObject( $res ) ) { - $revs[] = $row->rev_id; - } - $count = count( $revs ); - $this->output( "found $count.\n" ); +echo( "Erase Page Record\n\n" ); - # Delete the page record and associated recent changes entries - if( $delete ) { - $this->output( "Deleting page record..." ); - $dbw->query( "DELETE FROM $tbl_pag WHERE page_id = $id" ); - $this->output( "done.\n" ); - $this->output( "Cleaning up recent changes..." ); - $dbw->query( "DELETE FROM $tbl_rec WHERE rc_cur_id = $id" ); - $this->output( "done.\n" ); - } - - $dbw->commit(); - - # Delete revisions as appropriate - if( $delete && $count ) { - $this->output( "Deleting revisions..." ); - $this->deleteRevisions( $revs ); - $this->output( "done.\n" ); - $this->purgeRedundantText( true ); - } - - # Update stats as appropriate - if ( $delete ) { - $this->output( "Updating site stats..." ); - $ga = $isGoodArticle ? -1 : 0; // if it was good, decrement that too - $stats = new SiteStatsUpdate( 0, -$count, $ga, -1 ); - $stats->doUpdate(); - $this->output( "done.\n" ); - } - } else { - $this->output( "not found in database.\n" ); - $dbw->commit(); - } - } - - public function deleteRevisions( $ids ) { - $dbw = wfGetDB( DB_MASTER ); - $dbw->begin(); - - $tbl_rev = $dbw->tableName( 'revision' ); - - $set = implode( ', ', $ids ); - $dbw->query( "DELETE FROM $tbl_rev WHERE rev_id IN ( $set )" ); +if( isset( $args[0] ) ) { + NukePage( $args[0], true ); +} else { + ShowUsage(); +} - $dbw->commit(); - } +/** Show script usage information */ +function ShowUsage() { + echo( "Remove a page record from the database.\n\n" ); + echo( "Usage: php nukePage.php \n\n" ); + echo( " <title> : Page title; spaces escaped with underscores\n\n" ); } -$maintClass = "NukePage"; -require_once( DO_MAINTENANCE ); \ No newline at end of file -- cgit v1.2.3