26 require_once __DIR__ .
'/Maintenance.php';
35 parent::__construct();
37 $this->
addOption(
'delete',
"Actually delete the page" );
38 $this->
addArg(
'title',
'Title to delete' );
42 $name = $this->
getArg( 0 );
49 $this->
output(
"Searching for \"$name\"..." );
52 $id =
$title->getArticleID();
53 $real =
$title->getPrefixedText();
54 $isGoodArticle =
$title->isContentPage();
55 $this->
output(
"found \"$real\" with ID $id.\n" );
57 # Get corresponding revisions
58 $this->
output(
"Searching for revisions..." );
60 $revs = $dbw->selectFieldValues(
63 [
'rev_page' => $id ],
66 $count = count( $revs );
67 $this->
output(
"found $count.\n" );
69 # Delete the page record and associated recent changes entries
71 $this->
output(
"Deleting page record..." );
72 $dbw->delete(
'page', [
'page_id' => $id ], __METHOD__ );
73 $this->
output(
"done.\n" );
74 $this->
output(
"Cleaning up recent changes..." );
75 $dbw->delete(
'recentchanges', [
'rc_cur_id' => $id ], __METHOD__ );
76 $this->
output(
"done.\n" );
81 # Delete revisions as appropriate
82 if ( $delete && $count ) {
83 $this->
output(
"Deleting revisions..." );
85 $this->
output(
"done.\n" );
89 # Update stats as appropriate
91 $this->
output(
"Updating site stats..." );
93 $ga = $isGoodArticle ? -1 : 0;
100 $this->
output(
"done.\n" );
103 $this->
output(
"not found in database.\n" );
112 $dbw->delete(
'revision', [
'rev_id' => $ids ], __METHOD__ );
119 require_once RUN_MAINTENANCE_IF_MAIN;
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
getDB( $db, $groups=[], $dbDomain=false)
Returns a database to be used by current maintenance script.
addArg( $arg, $description, $required=true, $multi=false)
Add some args that are needed.
beginTransaction(IDatabase $dbw, $fname)
Begin a transaction on a DB.
commitTransaction(IDatabase $dbw, $fname)
Commit the transaction on a DB handle and wait for replica DBs to catch up.
output( $out, $channel=null)
Throw some output to the user.
hasOption( $name)
Checks to see if a particular option was set.
purgeRedundantText( $delete=true)
Support function for cleaning up redundant text records.
getArg( $argId=0, $default=null)
Get an argument.
addDescription( $text)
Set the description text.
addOption( $name, $description, $required=false, $withArg=false, $shortName=false, $multiOccurrence=false)
Add a parameter to the script.
Maintenance script that erases a page record from the database.
__construct()
Default constructor.
execute()
Do the actual work.
static factory(array $deltas)
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.