class DeleteOrphanedRevisions extends Maintenance {
public function __construct() {
parent::__construct();
- $this->mDescription = "Maintenance script to delete revisions which refer to a nonexisting page";
+ $this->addDescription(
+ 'Maintenance script to delete revisions which refer to a nonexisting page' );
$this->addOption( 'report', 'Prints out a count of affected revisions but doesn\'t delete them' );
}
$report = $this->hasOption( 'report' );
- $dbw = wfGetDB( DB_MASTER );
- $dbw->begin( __METHOD__ );
+ $dbw = $this->getDB( DB_MASTER );
+ $this->beginTransaction( $dbw, __METHOD__ );
list( $page, $revision ) = $dbw->tableNamesN( 'page', 'revision' );
# Find all the orphaned revisions
$res = $dbw->query( $sql, 'deleteOrphanedRevisions' );
# Stash 'em all up for deletion (if needed)
- $revisions = array();
+ $revisions = [];
foreach ( $res as $row ) {
$revisions[] = $row->rev_id;
}
# Nothing to do?
if ( $report || $count == 0 ) {
- $dbw->commit( __METHOD__ );
+ $this->commitTransaction( $dbw, __METHOD__ );
exit( 0 );
}
$this->output( "done.\n" );
# Close the transaction and call the script to purge unused text records
- $dbw->commit( __METHOD__ );
+ $this->commitTransaction( $dbw, __METHOD__ );
$this->purgeRedundantText( true );
}
*/
private function deleteRevs( $id, &$dbw ) {
if ( !is_array( $id ) ) {
- $id = array( $id );
+ $id = [ $id ];
}
- $dbw->delete( 'revision', array( 'rev_id' => $id ), __METHOD__ );
+ $dbw->delete( 'revision', [ 'rev_id' => $id ], __METHOD__ );
}
}