aboutsummaryrefslogtreecommitdiffstats
path: root/maintenance/nukePage.php
diff options
context:
space:
mode:
authorBrion Vibber <brion@users.mediawiki.org>2009-06-24 02:49:24 +0000
committerBrion Vibber <brion@users.mediawiki.org>2009-06-24 02:49:24 +0000
commit1c9773bd015adbf8aedb3b1777f0e087906baf6f (patch)
tree353da0a7f0f11723ebc93c301ed13528693e380d /maintenance/nukePage.php
parentceedb37941702f54766b107aee86e28559868304 (diff)
downloadmediawikicore-1c9773bd015adbf8aedb3b1777f0e087906baf6f.tar.gz
mediawikicore-1c9773bd015adbf8aedb3b1777f0e087906baf6f.zip
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!
Notes
Notes: http://mediawiki.org/wiki/Special:Code/MediaWiki/52340
Diffstat (limited to 'maintenance/nukePage.php')
-rw-r--r--maintenance/nukePage.php98
1 files changed, 14 insertions, 84 deletions
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 @@
<?php
+
/**
* Erase a page record from the database
* Irreversible (can't use standard undelete) and does not update link tables
@@ -8,92 +9,21 @@
* @author Rob Church <robchur@gmail.com>
*/
-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 <title>\n\n" );
+ echo( " <title> : Page title; spaces escaped with underscores\n\n" );
}
-$maintClass = "NukePage";
-require_once( DO_MAINTENANCE ); \ No newline at end of file