13require_once __DIR__ .
'/Maintenance.php';
27 parent::__construct();
29 $this->
addOption(
'delete',
"Actually delete the page" );
30 $this->
addArg(
'title',
'Title to delete' );
34 $name = $this->
getArg( 0 );
41 $this->
output(
"Searching for \"$name\"..." );
42 $title = Title::newFromText( $name );
43 if ( $title && $title->exists() ) {
44 $id = $title->getArticleID();
45 $real = $title->getPrefixedText();
46 $isGoodArticle = $title->isContentPage();
47 $this->
output(
"found \"$real\" with ID $id.\n" );
49 # Get corresponding revisions
50 $this->
output(
"Searching for revisions..." );
52 $revs = $dbw->newSelectQueryBuilder()
55 ->where( [
'rev_page' => $id ] )
56 ->caller( __METHOD__ )->fetchFieldValues();
57 $count = count( $revs );
58 $this->
output(
"found $count.\n" );
60 # Delete the page record and associated recent changes entries
62 $this->
output(
"Deleting page record..." );
63 $dbw->newDeleteQueryBuilder()
64 ->deleteFrom(
'page' )
65 ->where( [
'page_id' => $id ] )
66 ->caller( __METHOD__ )->execute();
67 $this->
output(
"done.\n" );
68 $this->
output(
"Cleaning up recent changes..." );
69 $dbw->newDeleteQueryBuilder()
70 ->deleteFrom(
'recentchanges' )
71 ->where( [
'rc_cur_id' => $id ] )
72 ->caller( __METHOD__ )->execute();
73 $this->
output(
"done.\n" );
78 # Delete revisions as appropriate
79 if ( $delete && $count ) {
80 $this->
output(
"Deleting revisions..." );
82 $this->
output(
"done.\n" );
86 # Update stats as appropriate
88 $this->
output(
"Updating site stats..." );
90 $ga = $isGoodArticle ? -1 : 0;
91 $stats = SiteStatsUpdate::factory( [
97 $this->
output(
"done.\n" );
100 $this->
output(
"not found in database.\n" );
109 $dbw->newDeleteQueryBuilder()
110 ->deleteFrom(
'revision' )
111 ->where( [
'rev_id' => $ids ] )
112 ->caller( __METHOD__ )->execute();
120require_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.
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.
commitTransactionRound( $fname)
Commit a transactional batch of DB operations and wait for replica DB servers to catch up.
purgeRedundantText( $delete=true)
Support function for cleaning up redundant text records.
beginTransactionRound( $fname)
Start a transactional batch of DB operations.
getPrimaryDB(string|false $virtualDomain=false)
addDescription( $text)
Set the description text.
Maintenance script that erases a page record from the database.
deleteRevisions(array $ids)
__construct()
Default constructor.
execute()
Do the actual work.