25 require_once __DIR__ .
'/Maintenance.php';
34 parent::__construct();
35 $this->
addDescription(
'Delete old (non-current) revisions from the database' );
36 $this->
addOption(
'delete',
'Actually perform the deletion' );
37 $this->
addOption(
'page_id',
'List of page ids to work on',
false );
41 $this->
output(
"Delete old revisions\n\n" );
47 # Data should come off the master, wrapped in a transaction
54 # If a list of page_ids was provided, limit results to that set of page_ids
55 if ( count(
$args ) > 0 ) {
56 $pageConds[
'page_id'] =
$args;
57 $revConds[
'rev_page'] =
$args;
58 $this->
output(
"Limiting to page IDs " . implode(
',',
$args ) .
"\n" );
61 # Get "active" revisions from the page table
62 $this->
output(
"Searching for active revisions..." );
63 $res = $dbw->select(
'page',
'page_latest', $pageConds, __METHOD__ );
66 $latestRevs[] = $row->page_latest;
68 $this->
output(
"done.\n" );
70 # Get all revisions that aren't in this set
71 $this->
output(
"Searching for inactive revisions..." );
72 if ( count( $latestRevs ) > 0 ) {
73 $revConds[] =
'rev_id NOT IN (' . $dbw->makeList( $latestRevs ) .
')';
75 $res = $dbw->select(
'revision',
'rev_id', $revConds, __METHOD__ );
78 $oldRevs[] = $row->rev_id;
80 $this->
output(
"done.\n" );
82 # Inform the user of what we're going to do
83 $count = count( $oldRevs );
84 $this->
output(
"$count old revisions found.\n" );
86 # Delete as appropriate
88 $this->
output(
"Deleting..." );
89 $dbw->delete(
'revision', [
'rev_id' => $oldRevs ], __METHOD__ );
90 $this->
output(
"done.\n" );
94 # Purge redundant text records
commitTransaction(IDatabase $dbw, $fname)
Commit the transcation on a DB handle and wait for replica DBs to catch up.
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
Maintenance script that deletes old (non-current) revisions from the database.
getDB($db, $groups=[], $wiki=false)
Returns a database to be used by current maintenance script.
hasOption($name)
Checks to see if a particular param exists.
require_once RUN_MAINTENANCE_IF_MAIN
doDelete($delete=false, $args=[])
addOption($name, $description, $required=false, $withArg=false, $shortName=false, $multiOccurrence=false)
Add a parameter to the script.
addDescription($text)
Set the description text.
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
output($out, $channel=null)
Throw some output to the user.
purgeRedundantText($delete=true)
Support function for cleaning up redundant text records.
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
beginTransaction(IDatabase $dbw, $fname)
Begin a transcation on a DB.