14require_once __DIR__ .
'/Maintenance.php';
27 parent::__construct();
29 'Maintenance script to delete revisions which refer to a nonexisting page' );
30 $this->
addOption(
'report',
'Prints out a count of affected revisions but doesn\'t delete them' );
34 $this->
output(
"Delete Orphaned Revisions\n" );
41 # Find all the orphaned revisions
42 $this->
output(
"Checking for orphaned revisions..." );
46 ->leftJoin(
'page',
null,
'rev_page = page_id' )
47 ->where( [
'page_namespace' =>
null ] )
48 ->caller(
'deleteOrphanedRevisions' )
51 # Stash 'em all up for deletion (if needed)
52 $count = count( $revisions );
53 $this->
output(
"found {$count}.\n" );
56 if ( $report || $count === 0 ) {
61 # Delete each revision
62 $this->
output(
"Deleting..." );
63 $this->deleteRevs( $revisions, $dbw );
64 $this->
output(
"done.\n" );
66 # Close the transaction and call the script to purge unused text records
78 private function deleteRevs( array $id,
IDatabase $dbw ) {
80 ->deleteFrom(
'revision' )
81 ->where( [
'rev_id' => $id ] )
82 ->caller( __METHOD__ )->execute();
86 ->deleteFrom(
'ip_changes' )
87 ->where( [
'ipc_rev_id' => $id ] )
88 ->caller( __METHOD__ )->execute();
94require_once RUN_MAINTENANCE_IF_MAIN;
Maintenance script that deletes revisions which refer to a nonexisting page.
execute()
Do the actual work.
__construct()
Default constructor.
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
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.