27require_once __DIR__ .
'/Maintenance.php';
41 parent::__construct();
43 $this->
addOption(
'delete',
"Actually delete the page" );
44 $this->
addArg(
'title',
'Title to delete' );
48 $name = $this->
getArg( 0 );
55 $this->
output(
"Searching for \"$name\"..." );
56 $title = Title::newFromText( $name );
58 $id = $title->getArticleID();
59 $real = $title->getPrefixedText();
60 $isGoodArticle = $title->isContentPage();
61 $this->
output(
"found \"$real\" with ID $id.\n" );
63 # Get corresponding revisions
64 $this->
output(
"Searching for revisions..." );
66 $revs = $dbw->newSelectQueryBuilder()
69 ->where( [
'rev_page' => $id ] )
70 ->caller( __METHOD__ )->fetchFieldValues();
71 $count = count( $revs );
72 $this->
output(
"found $count.\n" );
74 # Delete the page record and associated recent changes entries
76 $this->
output(
"Deleting page record..." );
77 $dbw->newDeleteQueryBuilder()
78 ->deleteFrom(
'page' )
79 ->where( [
'page_id' => $id ] )
80 ->caller( __METHOD__ )->execute();
81 $this->
output(
"done.\n" );
82 $this->
output(
"Cleaning up recent changes..." );
83 $dbw->newDeleteQueryBuilder()
84 ->deleteFrom(
'recentchanges' )
85 ->where( [
'rc_cur_id' => $id ] )
86 ->caller( __METHOD__ )->execute();
87 $this->
output(
"done.\n" );
92 # Delete revisions as appropriate
93 if ( $delete && $count ) {
94 $this->
output(
"Deleting revisions..." );
96 $this->
output(
"done.\n" );
100 # Update stats as appropriate
102 $this->
output(
"Updating site stats..." );
104 $ga = $isGoodArticle ? -1 : 0;
105 $stats = SiteStatsUpdate::factory( [
111 $this->
output(
"done.\n" );
114 $this->
output(
"not found in database.\n" );
123 $dbw->newDeleteQueryBuilder()
124 ->deleteFrom(
'revision' )
125 ->where( [
'rev_id' => $ids ] )
126 ->caller( __METHOD__ )->execute();
134require_once RUN_MAINTENANCE_IF_MAIN;
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
addArg( $arg, $description, $required=true, $multi=false)
Add some args that are needed.
getArg( $argId=0, $default=null)
Get an argument.
output( $out, $channel=null)
Throw some output to the user.
commitTransaction(IDatabase $dbw, $fname)
Commit the transaction on a DB handle and wait for replica DB servers to catch up.
addOption( $name, $description, $required=false, $withArg=false, $shortName=false, $multiOccurrence=false)
Add a parameter to the script.
hasOption( $name)
Checks to see if a particular option was set.
purgeRedundantText( $delete=true)
Support function for cleaning up redundant text records.
beginTransaction(IDatabase $dbw, $fname)
Begin a transaction on a DB handle.
addDescription( $text)
Set the description text.
Maintenance script that erases a page record from the database.
__construct()
Default constructor.
execute()
Do the actual work.