36require_once __DIR__ .
'/Maintenance.php';
46 parent::__construct();
47 $this->
addDescription(
'Remove pages with only 1 revision from any namespace' );
48 $this->
addOption(
'delete',
"Actually delete the page" );
49 $this->
addOption(
'ns',
'Namespace to delete from, default NS_MEDIAWIKI',
false,
true );
50 $this->
addOption(
'all',
'Delete everything regardless of revision count' );
54 $ns = $this->
getOption(
'ns', NS_MEDIAWIKI );
60 $tbl_pag = $dbw->tableName(
'page' );
61 $tbl_rev = $dbw->tableName(
'revision' );
62 $res = $dbw->query(
"SELECT page_title FROM $tbl_pag WHERE page_namespace = $ns" );
66 foreach (
$res as $row ) {
68 $title = Title::makeTitle( $ns, $row->page_title );
69 $id = $title->getArticleID();
72 $res2 = $dbw->query(
"SELECT rev_id FROM $tbl_rev WHERE rev_page = $id" );
75 foreach ( $res2 as $row2 ) {
76 $revs[] = $row2->rev_id;
78 $count = count( $revs );
81 if ( $all || $count == 1 ) {
82 # echo $title->getPrefixedText(), "\t", $count, "\n";
83 $this->
output(
"delete: " . $title->getPrefixedText() .
"\n" );
88 $dbw->query(
"DELETE FROM $tbl_pag WHERE page_id = $id" );
91 $child = $this->
runChild( NukePage::class,
'nukePage.php' );
92 $child->deleteRevisions( $revs );
97 $this->
output(
"skip: " . $title->getPrefixedText() .
"\n" );
102 if ( $n_deleted > 0 ) {
103 # update statistics - better to decrement existing count, or just count
105 $pages = $dbw->selectField(
'site_stats',
'ss_total_pages' );
109 [
'ss_total_pages' => $pages ],
110 [
'ss_row_id' => 1 ],
116 $this->
output(
"To update the database, run the script with the --delete option.\n" );
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two and(2) offer you this license which gives you legal permission to copy
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
beginTransaction(IDatabase $dbw, $fname)
Begin a transcation on a DB.
commitTransaction(IDatabase $dbw, $fname)
Commit the transcation on a DB handle and wait for replica DBs to catch up.
output( $out, $channel=null)
Throw some output to the user.
getDB( $db, $groups=[], $wiki=false)
Returns a database to be used by current maintenance script.
hasOption( $name)
Checks to see if a particular option exists.
purgeRedundantText( $delete=true)
Support function for cleaning up redundant text records.
runChild( $maintClass, $classFile=null)
Run a child maintenance script.
addDescription( $text)
Set the description text.
addOption( $name, $description, $required=false, $withArg=false, $shortName=false, $multiOccurrence=false)
Add a parameter to the script.
getOption( $name, $default=null)
Get an option, or return the default.
Maintenance script that removes pages with only one revision from the MediaWiki namespace.
execute()
Do the actual work.
__construct()
Default constructor.
require_once RUN_MAINTENANCE_IF_MAIN